MySQL ERROR 2002: Can't connect to local MySQL server through socket /var/run/mysqld/mysqld.sock

ERROR 2002 (HY000): can't connect to local mysql server through socket  '/var/run/mysqld/mysqld.sock' (2)

Solutions:-

systemctl status mysql
systemctl start mysql
systemctl list-units --type=service | grep mysql
nano /etc/mysql/mysql.conf.d/mysqld.cnf

note: ensure that the 'socket' directive in the configuration file points to the correct socket file it should look like:

socket = /var/run/mysqld/mysqld.sock
systemctl restart mysql
mysql -u root -p
mysql
sudo apt install make 

Last updated