[Problem] when using mysqli function in PHP to connect to mysql, the following error occurs: warning: mysqli: real_connect () :( hy0001040 ):. background: when mysql is changed to mysqli, there are too many connections. actually, this is not because I moved the sock file location of php, because these socket modifications were not completely modified, so the emergence of too connector connections, from mysql show processlist and did not find a real connection, in fact, the use of tshark to capture the package is estimated to see (http://justwinit.cn/post/7458/), and did not send a request, I guess it was reported by the mysqli client. don't look at this problem. after a long time, I wanted to reinstall Php, it turns out that the path is wrong, and the client of mysqli prompts that the number of connections is too large, leading to incorrect direction. As follows:
[Root @ iZ25z0ugwgtZ etc] # grep-r "mysql. sock ". /. /php. ini: pdo_mysql.default_socket =/data/runsock/mysqlsock/mysql. sock. /php. ini:; mysql. default_socket =/tmp/mysql. sock. /php. ini: mysql. default_socket =/data/runsock/mysqlsock/mysql. sock. /php. ini: mysqli. default_socket =/data/runsock/mysql. sock // This location is moved to/data/runsock/mysqlsock/mysql. caused by sock.
After modification, remember to restart php-fpm:
[Root @ iZ25z0ugwgtZ etc] # service php-fpm restart
Gracefully shutting down php-fpm. done
Starting php-fpm done
______________________ The troubleshooting points are as follows _______________________________
Warning: mysqli: real_connect (): (hy000/1040): too connector connections in:
Scenario: manually compile and install mysql and set the installation location. php connects to mysql in localhost mode.
Cause Analysis: all mysql files after manual compilation and installation are under the specified directory or data directory. by default, php only searches for/temp/mysql. the sock file cannot be found.
Solution:
1. create a soft link for the sock file
Ln-s/data/mysqldb/mysql. sock/tmp/mysql. sock;
Or
2. modify the default mysql. sock connection address of php.
Mysql. default_socket =/data/mysqldb/mysql. sock
3. tcp socket connection
Mysql ('127. 0.0.1 ', 'username', 'passwod ');
From: http://ju.outofmemory.cn/entry/144221