How to solve "Can't connect to local MySQL server through socket" error?
Check the folowing


First check if another instance is runnig 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