[Problem] when mysql is connected using mysqli function in PHP, the following error occurs: warning: mysqli: real_connect () :( hy000/1040 ):.

Source: Internet
Author: User
[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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.