Done!

Can't connet to local MySQL server through mysqld.sock


Sometime the system startup script that lunched the command line executable specifies a flag --socket=path. This flag could override the my.cnf location, and this would result in a socket not being found where the my.cnf file indicates it should be. Then when you try to log into mysql via phpmyadmin to will get error as :

Connection for controluser as defined in your configuration failed.

Further, when you try to connect the mysql via command line you could get following error

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

Solution - on ubuntu

//If you are super user in the linux system, based on the above just do this:
kill -9 4969

//or sometimes you can do this:
pkill -9 mysqld

//restart the mysql server
sudo /etc/init.d/mysql restart

Solution - on Centos

-> cd /var/lib/mysql

//backup
->sudo mv mysql.sock 

-> sudo su

-> service mysqld restart

Do you know, any other solution for other operation system? Please advise us with your solution on the comment below. - Thanks