This article mainly introduces how to solve the problem of too many MySQLSleep connections. many MySQLSleep connections are usually caused by the client's failure to close the connection. the solution is simple. just modify the configuration file, for more information about how to run show processlist in mysql, you can see that there are many such processes in the database:
There are three reasons for sleep:
1. before the client program exits, it does not call mysql_close (). [write program negligence, or the database class library does not automatically close each connection...]
2. the client sleep does not send any request to the server within the seconds specified by wait_timeout or interactive_timeout. [similar to a common connection, similar to an incomplete tcp IP protocol structure, the server always thinks that the client still exists (it is possible that the client has been disconnected)]
3. before the client end, the client end up sending a request to the server without returning the result. [refer to the three-way handshake of tcp IP protocol]
The solution is also simple.
Add
The code is as follows:
[Mysqld]
Wait_timeout = 10
Or
The code is as follows:
Mysql> set global wait_timeout = 10;