5

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)

0

3 Answers 3

7

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 
Sign up to request clarification or add additional context in comments.

1 Comment

it doesnt work on ubuntu 22
0

In my case not install mariadb server, You can try here

sudo apt install mariadb-server 

Comments

0

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 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.