Can’t connect to local MySQL server through socket…error.
Posted on Friday the 21st of September, 2007 at 6:08 am in Asides, Computers, Dev, LinuxI recently moved my /home folder to its own partition, but in doing so, I broke MySQL. The full error I got was:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
To fix this you need to create the file and make sure that MySQL has access to it. (All commands need to be run as root)
Create the directory (if it doesn’t already exist).
sudo mkdir /var/run/mysqld/Create the file by “touching” it.
sudo touch /var/run/mysqld/mysqld.sockSet the ownership of the mysqld.sock file and folder to mysql.
sudo chown -R mysql /var/run/mysqld/You can then start MySQL and breath easier.


i’ve followed your instruction, then it came out like this
root@razman-laptop:~# mysql -u root -p
Reply to razmanEnter password:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (111)
I had the same problem and got the same error as razman after this ‘fix’
Reply to Brendan LewisI have same problem…
Same answers again and again.
Again another unsolved problem. Noone seems to investigate what the heck is going on.
It seems the OS have to be reinstalled.
Ubuntu for Human DOING!
Reply to MariusThe provided solution works when I logged in as root but when I logged in as another user I face the same error. Dont know what the problem is..
Reply to Prashant Agarwali killed the mysqld process, and restarted mysql, it created mysqld.sock file automatically
everything works fine
Reply to govind