mysqld: unrecognized service

August 11, 2014 27.7k views


I have a problem with my MySQL server. I can’t connect to MySQL via command line. If I try it, I get:

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

My directory /var/mysql is empty. And if I try

/etc/init.d/mysql restart

I get “[fail]”.

Moreover, if I type

service mysqld restart

I get “mysqld: unrecognized service”.

However, my website (which uses this database) works fine.

Thank you very much ;)

1 comment
  • The service name is ‘mysql’ not 'mysqld’. Please confirm the status of the service by typing 'service mysql status’

    Also you indicated that you check the /var/mysql directory, but the socket file should be located in /var/run/mysqld/ directory.

2 Answers

As ahrotahntee mentioned, the correct command to restart a MySql service is:

service mysql restart

One instance when you will see the error ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) is when you have run out of room on your hard drive. How is your disk utilization looking? You can check by running:

df -h
  • Ah, thanks for that tip. This was my problem – hard drive was full. Upgrading to a larger hard drive fixed the problem


Thank you very much! I’ve solved this! ;)

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!