Mysql – Can’t start MYSQL after changing directories

databasedirectoryMySQL

So I started running out of space on my linux hard disk. I added another hard drive and now I want to change the MySQL directories. So instead of saving the data into the old hard drive, it saves it into the new hard drive. The new hard drive is mounted as /Data/

I looked several ways to do it, and I followed each and every instruction. But every time I followed the instructions I get an error "ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'"

I tried moving the directory and then linking the old directory to the new one. Same error.

I tried moving the whole directory and changing the my.cnf file under etc to point at the new directory, I even changed the line socket=/Data/mysql/mysql.sock still the same error.

**Also, I did make sure all the ownerships were mysql:mysql

It fails to start each time. So I end up moving everything back to where it was and it starts successfully. I would really appreciate some help here.

Thanks!

Best Answer

In the my.cnf you need to add the socket path in two places: In the [mysql] and in the ->[client]<- section.

Here is a typical global option file:

[client]
port=3306
socket=/tmp/mysql.sock

[mysqld]
port=3306
socket=/tmp/mysql.sock