ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysql.sock’
When I tried to connect mysqld server, I got this error.
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysql.sock’
1. Check whether mysqld server is running or not, using the below command
ps -ef | grep mysql
If mysqld is running, then check the socket path in the .cnf file and give the correct path when connecting.
2. Check the file permission of that socket file. If the file doesn’t have mysql permission, just change permission to mysql using the below command.
chown mysql:mysql sockfile_path
3. If the socket file is missing then you have to restart your mysqld server.
One Response to “ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysql.sock’”
There can be few more reasons for this issue.
1. There is already some instance of MySQL running and the new instance is not able to update/start with the same socket file name.
“101012 20:21:30 [ERROR] Do you already have another mysqld server
running on socket: /var/run/mysqld/mysqld.sock ?”
2. The folder path as mentioned in cnf does not exist.
3. The folder does not have ownership for mysql user (if you are starting as mysql user)
Leave a Reply
You must be logged in to post a comment.