ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
Some times you may face this error while connecting to database through MySQL client even though the services are running fine. Here its clear from the error that its connecting to the wrong socket. This is happens when MySQL service using socket path other than the default one.
In-order to fix this issue check the correct socket path for MySQL service.
#ps -aux | grep mysql
Update the same in mysql config file /etc/my.cnf.
Here we need to replace the socket file path accordingly. Pleas make sure that you are updating this parameter under '[client]' section.
Now we can connect to database through MySQL client without any issues.