Today, the server encountered a very familiar problem
Input
#mysql-U root-p
ERROR 2002 (HY000): Can ' t connect to local MySQL server
Search the Internet for answers
I'll try it one by one, according to the way everyone offers
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
His trouble has been solved, and mine has not been solved!
Keep looking
Scenario 2
Check/etc/rc.d/init.d/mysqld status first to see M y s Q l Whether it has been started. Also see if it is a permissions 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-penter password:welcome To the MySQL Monitor. Commands End With; Or/g.your MySQL Connection ID is 3-to-server Version:4.1.11type ' help; ' or ' H ' for help. Type '/C ' to clear the Buffe
His also solved, my trouble continues, still continue to look for
Scenario 3
Problem solved, unexpectedly is max_connections=1000 he said too much, and then changed to 500 also said more, but delete the problem solved.
Or not?
Scenario 4
/var/lib/mysql all file permissions to Mysql.mysql
No, No.
Scenario 5
Summary: Resolve cannot pass MySQL
. Sock connection to MySQL problem The main tip is that you cannot connect to the server through the '/tmp/mysql. Sock ', while the PHP standard configuration is using '/tmp/mysql. Sock ', but some MySQL installation methods will be MySQL. Sock on/ 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:
[Mysqld] 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 also modify the P Hp.ini in the configuration to make PHP with 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
Ok!
Database problem (program connection MySQL error)