Today, when connecting to the MySQL database, I encountered a problem: Can ' t connect to the local MySQL server through socket '/tmp/mysql.sock ' (2)
Programme 1.
1. #ps-a|grep MySQL
Display 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
His trouble has been solved, mine is not solved!
Keep looking
Programme 2
First look at the/etc/rc.d/init.d/mysqld status to see if the M y S Q has been started.
Also see if it's a permission issue.
------------------------------------------------------------------------------------
[Root@localhost Beinan] #chown-R mysql:mysql/var/lib/mysql
[Root@localhost beinan]#/etc/init.d/mysqld start
Start MySQL: [OK]
[root@localhost lib]# mysqladmin-uroot password ' 123456 '
[Root@localhost 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
His work was resolved, my troubles continued, and the search continued.
Programme 3
Problem solved, unexpectedly is max_connections=1000 he said too much, and then changed to 500 also say more, but delete the problem solved.
No, not yet.
Programme 4
/var/lib/mysql all file permissions to Mysql.mysql
No, No.
Programme 5
Absrtact: Resolve cannot pass MySQL. Sock connection MySQL problem The main clue is that you cannot connect to the server through '/tmp/mysql. Sock ', and the PHP standard configuration is using '/tmp/mysql. Sock ', but some MySQL installation methods will MySQL. Sock in/var/lib/mysql sock or somewhere else, you can modify the/etc/my.cnf file to fix it, open the file, and you can see the following:
[MySQL d]
Socket=/var/lib/mysql. Sock
The change is good, but also can cause other problems, such as MySQL program can't even, add a little:
[MySQL]
Socket=/tmp/mysql. Sock
Alternatively, you can modify the configuration in php.ini to make PHP use the other MySQL. Sock, this one's going to find it.
Or in this way:
Ln-s/var/lib/mysql/mysql. Sock/tmp/mysql Sock
Successful, that's how Ln-s/var/lib/mysql/mysql. Sock/tmp/mysql Sock
Ok!
But my system did not find mysql.sock files, only mysqld.sock files,/var/run/mysqld/mysqld.sock
So imitate the above practice: Ln-s/var/run/mysqld/mysqld.sock/tmp/mysql.sock
In this way, you can connect to the database properly.