Solutions to problems related to unstable connection between PHP and mysql

Source: Internet
Author: User
The connection between PHP and mysql is unstable. when the program is executed, both CantconnecttoMySQLserveron127.0.0.1 (10061) and CantconnecttoMySQLserveron127.0.0.1 (10048) may appear from time to time, but refresh will make the program okay, and there will be no connection problems, but occasionally this PHP and mysql connection is unstable, find a solution
Can't connect to MySQL server on '2017. 0.0.1 '(127) or
Can't connect to MySQL server on '2017. 0.0.1 '(127)
Both of them will appear, but refresh will be fine.
There is no problem with the program, and there is no problem with the connection, but occasionally these two errors will be reported, self-written code, the following form
$ Con = mysql_connect ("localhost", "mysql_user", "mysql_pwd ");
If (! $ Con)
{
Die ('could not connect: '. mysql_error ());
}

The first localhost was replaced with 127.0.0.1, which did not solve the problem.

------ Solution --------------------
This may be caused by the number of mysql connections. modify the mysql. ini configuration.
------ Solution --------------------
What is the website access volume?
How is the server configured?
What happened?
Use a common PHP program for stress testing and try again.

It is initially suspected that the network or server is unstable.
Observe the CPU and memory usage of the server.
------ Solution --------------------
It's nothing more than a large traffic volume or a network problem. check that LZ accounts for most of the reasons ,,

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.