In this article, we will see the solution for below error.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Reasons:
1. MySQL is not started.
2. MySQL not installed on your machine.
Solution:
1. Lets verify the status of mysql server whether it is started or not.
service mysql status
If not installed also, we will receive the above error message.
2. That error means the file /var/run/mysqld/mysqld.sock doesn’t exists, if you didn’t install mysql-server, then the file would not exist. So in that case, install it with
sudo apt-get install mysql-server