I\'m getting this error
ERROR 2002 (HY000): Can\'t connect to local MySQL server through socket \'/var/run/mysqld/mysql.sock\' (2)
even though
This is an old tread with different solution proposed, but none of them worked for me. I'm adding this answer in the hope it will help somebody who struggled as me for some time.
I've checked all the existing answers and all the existing solution, but for me the issue was incorrect user permission on var/run/mysql folder.
I've checked the user permission on that folder and it was set to root. Once i changed to mysql:mysql the problem has gone.
So enter into /var/run/mysqld and change the user permission to:
chown -R mysql:mysql .