Ubuntu 11.04 - Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13)

Jamie Hutber picture Jamie Hutber · Nov 23, 2011 · Viewed 35.9k times · Source

I have googled for 2 days now and was initially get a

'/var/run/mysqld/mysqld.sock' (2)

I fixed this by using:

sudo touch /var/run/mysqld/mysqld.sock
sudo chown -R mysql /var/run/mysqld/

now i get the error:

 '/var/run/mysqld/mysqld.sock' (13)

So everything has the correct permissions and the file exists. Any thoughts?

[Edit]

Got it working, although i am unsure how. I did aa-logprof as root, nothing changed, got angry and then re-set it started working.

Answer

aviggiano picture aviggiano · Sep 6, 2013

In my case, running mysqld_safe created a new mysqld.sock file.

$ cd /etc/init.d/
$ mysqld_safe

You'll probably won't get the prompt back, but if you restart your session, a mysqld.sock file will be somewhere. Find it with

$ sudo find / -type s | grep mysqld.sock