1. How to resolve the error - can't connect to the local mysql server through socket '/var/lib/mysql/mysql.sock' (2)?
Description: I kept getting this following error every time I tried to restart MySql. It was working fine before I changed the default data directory. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib /mysql/mysql.sock' (111) I know there are other solutions posted by others but none of them worked for me.
To resolve the error - can't connect to local mysql server through socket '/var/lib/mysql/mysql.sock' (2) -
Check the following First check if another instance is running in the same machine ps ax | grep mysql Then, check if your file my.cnf (probably in /etc/mysql/ folder) is correctly configured with
[mysqld]
datadir = /var/lib/mysql/
socket = /var/lib/mysql/mysql.sock
Next, you have changed the default data directory, did you gave the right permissions to the new directory now
chown mysql:mysql -R /var/lib/mysql/*
chmod 755 -R /var/lib/mysql/*
After changing the permission restart the service and check
service mysql restart