Could not connect: Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’
If you are getting above error it means “mysql.sock” file is not available at /var/lib/mysql
login to server as root
root@server []#killall -9 mysqld
root@server []#service mysql start
root@server []#service mysql restart
If still mysql.sock is not created under /var/lib/mysql then,
Go to /tmp
We will found there mysql.sock in red color
Delete it from /tmp
Service mysql restart
This should create mysql.sock file at /var/lib/mysql
Use the below command to create it
root@server []#ln -s /var/lib/mysql/mysql.sock mysql.sock
then restart mysql and check
root@server []#service mysql restart

There is same error for below :-
Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’
You need make some changed in mysql configuration file i.e /etc/my.cnf .
Tkae a backup of the file before making any change.
root@server []# cp etc/my.cnf etc/my.cnf_bk
Go to /etc/my.cnf with your favorite editor and search for line
root@server []# vi /etc/my.cnf

And just comment the last line.


The error will fixed 😀