dev752684
By:
dev752684

mysqld: unrecognized service

August 11, 2014 19.5k views

Hi!

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

Hi!

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

Have another answer? Share your knowledge.