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.

I just upgraded my MySQL server on Debian. However now when I start the server and try connect to it I get the error:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

How can I fix this?

share|improve this question
    
Did the MySQL service successfully start? Check its log. –  Shane Madden May 16 '12 at 16:53
    
It starts, but no process shows up. –  Markum May 16 '12 at 21:07
    
I had this error just now, and it turned out to be an error in the configuration file which I had just modified. –  linitbuff Jan 5 '13 at 7:39

4 Answers 4

I know this question is five months old, but since I've run into the same problem on three different upgrades, I thought I'd post my solution anyway.

In my case, this seems to be due to a bug in the Debian update scripts (so the problem might crop up in Ubuntu as well). Somehow, some of the binary log files wind up with the wrong ownership after the upgrade process is complete. This prevents the server from gaining write access to its own logs, so it fails to start.

On Debian (at least on our servers) these files all live in /var/lib/mysql. Everything in there should be owned by user mysql and group mysql. However, some of the files mysql-bin.* were owned by root after the upgrade. Changing the ownership of the logfiles back to mysql allowed the server to start correctly:

# chown mysql:mysql /var/lib/mysql/mysql-bin.*
# /etc/init.d/mysql start

I hope this saves someone some time.

share|improve this answer

Try the following

mkdir /var/run/mysql
chown mysql:mysql /var/run/mysql

Then start mysql...

share|improve this answer
    
Done, but nothing happens when I do service mysql start, or stop. But when I do stop it and use the client it still gives me the error, as if it was still on. I think I may have two MySQL servers conflicting. –  Markum May 16 '12 at 21:09

MySQL most likely failed to start. Try running ps aux | grep mysqld to see if there's a process ID for the mysql daemon.

To expand on Shane's comment, check the MySQL log for reasons for it failing to start. The default location is /var/log/mysql/error.log

share|improve this answer
    
Nope, no process. And there is no error lo file. –  Markum May 16 '12 at 21:07

First start the mysql server

then run this command

ln -s /var/lib/mysql/mysql.sock /var/run/mysqld/mysqld.sock
share|improve this answer

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.