Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

MySQL server was installed and was running just fine. Today we can't connect to the database via our websites. Command line access using mysql -u username -p also fails. Finally, phpmyadmin fails.

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

service mysql restart
stop: Unknown instance:
start: Job failed to start

Error logs (/var/log/mysql/error.log & /var/log/mysql.err & /var/log/mysql.log) are all empty for the past week. The problem just began today.

I have looked at lots of answers including Ubuntu Error 2002 “Can't connect to local MySql server through socket…” and ERROR 2002 (HY000): Can't connect to local MySQL.

Should I just reinstall mysql server and chalk it up as an unknown error? (horrible idea, obviously).

What is the right course of action to fix immediately and prevent from reoccurring?

share|improve this question
have you tried killing off any existing mysql processes with kill, and deleting the files under /var/run/mysqld? Or maybe rebooting? – Zoredache Apr 18 '13 at 22:36
Rebooting did not help. I have not tried kill nor delete. One more point... I need to maintain all mysql databases and data. – csi Apr 18 '13 at 22:43
Can you post the result of ps aux | grep mysql? – Spack Apr 18 '13 at 22:51
Added to question – csi Apr 18 '13 at 23:00
Make sure you are not out of diskspace. That could kill your mysql. Also, make sure your sock file is deleted. I think my.cnf will tell you where it creates the mysql.sock file. – Nikolas Sakic Apr 19 '13 at 4:05
up vote 1 down vote accepted

I changed the bind-address from the IP to Still not sure why this worked and then all of a sudden stopped. Here is the solution for others.

sudo nano /etc/mysql/my.cnf


bind-address = ""

And then

sudo service mysql restart
share|improve this answer
Just one question why you restarted apache2 after changing my.cnf file? – Abhishek Anand Amralkar Apr 19 '13 at 5:25
Edited - did not restart apache, restarted mysql. Sorry about the typo. It is corrected. – csi Apr 22 '13 at 13:53
my bind address has always been set to and this is a regular occurance on more than 1 of my servers. – Dez Jan 4 at 16:26

Your Answer


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.