What should I do , if I receive the following error while refreshing mysql on the server ?

Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)

Refer the below steps to solve this:

a.Check the ownership of “/var/lib/mysql” and its files and subdirectories in  mysql user of mysql group.

To reset the ownership run the following command:

cd /var/lib/mysql
chown mysql.mysql -R /var/lib/mysql/*

b. Check the permissions of mysql directory, and all its files and subdirectories.

It must be set to rwxr-xr-x (755).

To reset the permission Run the following command:

chmod 755 -R /var/lib/mysql/*

C.Refresh mysql service now using the below command :-

service mysql start

The  error message should disappear and you should see the below output :-

Starting MySQL. [ OK ]

Share on Twitter
Share on Facebook