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


I came across the strange problem today while installing mysql server on my ubuntu 10.04 LTS . I have installed various mysql client in many system before but came across this error for the first time. I got this error while I was installing the Koha. The full error message i came across is “ ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2) “. This is the error message while I am trying to execute “mysql -u root -p”. After giving root password above message is diplayed. The solution for this problem is : Create the directory if not exists.

  • mkdir /var/run/mysqld/

Create the file mysqld.sock in mysqld directory if not exist.

  • touch /var/run/mysqld/mysqld.sock

Change the ownership as

  • chown -R mysql /var/run/mysqld/

After these step also I coulnot get solution. My mysql was not running till. Then I comment the line in mysql configuration file for this line as. For this run [email protected]:~# vi /etc/mysql/my.cnf # bind-address = Thene I rebooted my Ubuntu machine. Now Mysql works like charm.