I have yum install mysql in CentOS 6.4. Now, when I use mysql command, it throws the following error:

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

When I check the directory there is no mysql folder. How should I solve this problem? It's worth mentioning when I do service mysql start (or with mysqld) it errors unrecognized service.

I should mention that I have changed the path in my.cnf but nothing happens. The problem is that no *.sock file exists at all.


Results of checking mysql process with mysqladmin -u root -p status returns:

mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!

Also when I directly want to run /etc/init.d/mysqld it errors that it cannot resolve the ip (localhost.localdomain).

Second Update:

I have run the command [root@localhost /]# rpm -qa | grep mysql

and it returns:

  • 2
    Did you start the mysql process? Is it running?
    – Citylight
    Jan 4 '15 at 9:22
  • Have you tried changing path from "/var/run/..." to /var/lib/..." in my.cnf? Also, run ps aux | grep mysql
    – kirill-a
    Jan 4 '15 at 10:20
  • Check if you have this line in /etc/hosts localhost.localdomain
    – Boban P.
    Mar 23 '16 at 7:38
  • and give us a my.cnf
    – Boban P.
    Mar 23 '16 at 7:39

If your file my.cnf (usually in the /etc/mysql/ folder) is correctly configured with


you can check if mysql is running with the following command:

mysqladmin -u root -p status

try changing your permission to mysql folder. If you are working locally, you can try:

sudo chmod -R 755 /var/lib/mysql/


  • please see the question is updated Jan 4 '15 at 10:19
  • And it's worth I'm root user. No need for chmod Jan 4 '15 at 10:20

Looks like you just installed MySQL client not the server. Use the command below to install the server yum install mysql-server

Also you can refer the link for more information:- MySQL

  • I have installed it. Look at my updated question. Thanks you Jan 4 '15 at 11:18
  • check the binding of MySQL using the command lsof -i:3306 may be it's not listening on localhost
    – Karthik
    Jan 4 '15 at 17:47

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.