1

I have this error:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")

Anyone know what is wrong? It seems it isn't installing mysqld.sock, when I run apt-get install mysql-server. I tried find / -name "mysqld.sock" but it can't find anything. How can I get mysqld.sock?

migrated from stackoverflow.com Aug 13 '18 at 2:23

This question came from our site for professional and enthusiast programmers.

  • Did you start the mysql server? Is it configured to use a unix socket at that path? – Shawn Aug 12 '18 at 23:14
2

It should not install mysqld.sock. This file is a unix socket, it doesn't refer to a byte stream on your hard disk.

It is more like a TCP port: programs can listen here, and other programs can connect it to communicate with it. The only significant different is that TCP ports are identified by a number between 1 and 65535. Unix sockets are identified by their path, like /var/run/mysql/mysqld.sock.

mysqld.sock is created by the mysql daemon on start, and it is removed (or, becomes un-connectable) if this daemon stops.

This message is given by some client process, trying to connect your mysqld on this socket without success.

Its most likely reason is that the mysqld doesn't run.

Why it doesn't run? Try to start it (systemctl start mysqld) and check the /var/log/mysql* .

  • in errror.log i've got this error. 2018-08-13 10:43:09 139999537754688 [ERROR] Can't start server: Bind on TCP/IP port. Got error: 98: Address already in $2018-08-13 10:43:09 139999537754688 [ERROR] Do you already have another mysqld server running on port: 3306 ? 2018-08-13 10:43:09 139999537754688 [ERROR] Aborting – Jirka Kastan Aug 13 '18 at 8:45
  • Check what is listening on that socket with an lsof -n -P|grep -F 3306|grep -F LISTEN. – peterh Aug 13 '18 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.