How to solve the problem of too many MySQL Sleep connections: mysqlsleep

Source: Internet
Author: User

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;

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.