'ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) help me

Can someone help me? I've tried searching for a few ways to fix it, but no success!

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



Solution 1:[1]

To solve this issue you need to stop mysql process either through:

systemctl stop mysql

or

service mysql stop

after than you’ll need to expose the directory which has the socket configurations to the user who is running the process, this can happen through:

sudo usermod -d /var/lib/mysql/ mysql

then go back and start / restart mysql process again through:

systemctl start mysql

or

service start mysql

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1