Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!

share|improve this question
    
can you show us your mysql logfile? –  Pascal Schmiel Apr 30 '13 at 14:13
    
Is the new directory mysql:mysql ? –  NickW Apr 30 '13 at 14:16
2  
This is just to check, did your mysql server instance crashed the last time when it ran out of disk space? If so, then your old mysql.sock file still exists. Make sure the old mysql.sock file is deleted before you start mysql server. –  Nikolas Sakic Apr 30 '13 at 14:19
    
Thanks for the reply guys. No my server didn't crash. Like I mentioned, I can start it successfully if I leave everything as default. But as soon as I try to move the directory it won't start. –  Zors Apr 30 '13 at 14:48
add comment

2 Answers

Once you move everything to the new folder you need to make sure that the folder has permissions and ownership mysql:mysql.

share|improve this answer
    
Thanks for the reply. I did check all the ownerships and made sure all of them are mysql:mysql –  Zors Apr 30 '13 at 14:43
    
Is there anything else in /var/log/mysql/mysql.log or error.log? –  Danila Ladner Apr 30 '13 at 14:47
    
What OS it is installed on? –  Danila Ladner Apr 30 '13 at 14:56
    
The Operating System is CentOS –  Zors Apr 30 '13 at 15:01
add comment

The error you are getting is not one you get from starting mysql with things in the wrong place, but from the fact that you need to modify the socket location in the [client], `[mysqld] and any other location it shows up in, under my.cnf

share|improve this answer
    
I changed the socket file to the new destination under [mysqld] however [client] doesn't exist in my my.cnf file. Should I just add [client]? –  Zors Apr 30 '13 at 14:51
    
There may be another location where it is configured, but even the client has to know where to connect to by default (if you don't put -h ). –  NickW Apr 30 '13 at 14:54
    
I just tried to add [client] to the file and it still failed to start. [root@localhost etc]# service mysqld start mysMySQL Daemon failed to start. Starting mysqld: [FAILED] [root@localhost etc]# mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Data/mysql/mysql.sock' (2) –  Zors Apr 30 '13 at 14:54
    
in your my.cnf do you have option: basedir=/var/lib? –  Danila Ladner Apr 30 '13 at 15:05
    
No [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid –  Zors Apr 30 '13 at 15:07
show 7 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.