I have the following error, but when I try to find the socket file there is in fact nothing

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

I have MariaDb on a ubuntu 18.04 How can I add this socket? I used to work with mysql but I am a bit lost with MariaDb as they replicated config everywhere


nothing related to mysql / mariadb here


nicolas@nicolas-UX530UX:/var/run$ ls /var/run/mysqld/mysqld.sock
ls: cannot access '/var/run/mysqld/mysqld.sock': No such file or directory
nicolas@nicolas-UX530UX:/var/run$ service mysql status
Unit mysql.service could not be found.
  • 1
    Can you make ls /var/run/mysqld/mysqld.sock and service mysql status. – ob2 Aug 20 '18 at 9:43
  • I updated my EDIT 1, please check – Nicolas D Aug 20 '18 at 9:45
  • ok I found my mistake, I had installed only mariadb-client and not server! sorry – Nicolas D Aug 20 '18 at 9:49
  • Happy to help you. – ob2 Aug 20 '18 at 10:14

Solution 1:

Make sure that you have installed the mysql-server, not the mysql-client or something else. If you didn't install mysql-server, then the file would not exist. So install mysql-server.

Solution 2:

If the mysql-server is already installed and is running, then you need to check the config files.

The config files are located at:




In /etc/my.cnf, the socket file config may be /tmp/mysql.sock


in /etc/mysql/my.cnf the socket file config may be /var/run/mysqld/mysqld.sock.

So, remove or rename /etc/mysql/my.cnf, and let mysql use as /etc/my.cnf.

| improve this answer | |

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.