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 ,,