Reputation: 59
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)
Upvotes: 5
Views: 29896
Reputation:
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 mysql start
Upvotes: 7
Reputation: 874
If you have this error during the process to install mariadb (exemple) :
Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)
You have to start mariadb in the first place :
systemctl start mariadb
Or if you are using WSL :
service start mariadb
Upvotes: 0
Reputation: 873
In my case not install mariadb server, You can try here
sudo apt install mariadb-server
Upvotes: 0