ERROR 2002 (HY000): Can ' t connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock ' (2)
Error:
Input
#mysql-U root-p
ERROR 2002 (HY000): Can ' t connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock ' (2)
Scenario 1.
1. #ps-a|grep MySQL
Show similar:
1829? 00:00:00 Mysqld_safe
1876? 00:00:31 mysqld
2. #kill-9 1829
3. #kill-9 1876
4.#/etc/init.d/mysql restart
5. #mysql-U root-p
Scenario 2
Check the/ETC/RC.D/INIT.D/MYSQLD status first to see if M y S Q L has been started.
Also see if it is a permission issue.
————————————————————————————
[[email protected] Beinan] #chown-R mysql:mysql/var/lib/mysql
[[email protected] beinan]#/etc/init.d/mysqld start
Start MySQL: [OK]
[Email protected] lib]# mysqladmin-uroot password ' 123456 '
[Email protected] lib]# mysql-uroot-p
Enter Password:
Welcome to the MySQL Monitor. Commands End With; Or/g.
Your MySQL Connection ID is 3 to server version:4.1.11
Type ' help; ' or '/h ' for help. Type '/C ' to clear the Buffe
Scenario 4
/var/lib/mysql 所有文件权限 改成mysql.mysql
Scenario 5
Summary: Troubleshooting cannot be done via MySQL. Sock connection MySQL problem The main hint is that you cannot connect to the server through '/tmp/mysql. Sock ', while the PHP standard configuration uses '/tmp/mysql. Sock ', but some MySQL installation methods will MySQL. Sock placed in/var/lib/mysql sock or somewhere else, you can modify the/etc/my.cnf file to fix it, open the file, you can see the following:
[MySQL d]
Socket=/var/lib/mysql. Sock
Change it, but it will also cause other problems, such as the MySQL program is not connected, add a bit:
[MySQL]
Socket=/tmp/mysql. Sock
Or you can modify the configuration in the php.ini to make PHP use the other MySQL. Sock, this is for everyone to find.
Or in such a way:
Ln-s/var/lib/mysql/mysql. Sock/tmp/mysql. Sock
That's it, Ln-s/var/lib/mysql/mysql. Sock/tmp/mysql. Sock
ERROR 2002 (HY000): Can ' t connect to local MySQL