How to solve the problem of too many MySQL Sleep connections: mysqlsleep
Sometimes you run show processlist in mysql, and then you will find 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
Copy codeThe Code is as follows:
[Mysqld]
Wait_timeout = 10
Or
Copy codeThe Code is as follows:
Mysql> set global wait_timeout = 10;