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?

  • 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, 2013 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, 2013 at 22:43
  • Can you post the result of ps aux | grep mysql?
    – Spack
    Apr 18, 2013 at 22:51
  • Added to question
    – csi
    Apr 18, 2013 at 23:00
  • 1
    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. Apr 19, 2013 at 4:05

1 Answer 1


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
  • Just one question why you restarted apache2 after changing my.cnf file? Apr 19, 2013 at 5:25
  • Edited - did not restart apache, restarted mysql. Sorry about the typo. It is corrected.
    – csi
    Apr 22, 2013 at 13:53
  • my bind address has always been set to and this is a regular occurance on more than 1 of my servers. Jan 4, 2016 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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