Mysql solves automatic disconnection of links that have never been used for 8 hours _ MySQL

Source: Internet
Author: User
Mysql solves the problem of automatically disconnecting the link bitsCN.com that has never been used for 8 hours.

Mysql automatically disconnects links that have not been used for 8 hours

Recently, many colleagues in the department reported that the database connection was automatically disconnected during mysql usage. I did some experiments on the problem.

The results of the study on mysql automatic disconnection are as follows. related parameter settings are available in mysql. when the database connection is idle for a certain period of time, the server

Will disconnect the connection waiting for timeout:

At the same time, only one of these two parameters works. Which parameter takes effect depends on the connection parameter specified during user connection. by default

Wait_timeout. I suggest modifying both parameters to avoid unnecessary troubles.

2. modify parameters

The default values of these two parameters are 8 hours. I tested changing these two parameters to 0, and the result is unexpected. The system automatically sets this value to 1. In other words, you cannot set this value to permanent. We recommend that you add three zeros to the parameter value to meet our application requirements.

Modify: open/etc/my. cnf and add the following parameters under the property group mysqld:

[Mysqld]

Interactive_timeout = 28800000

Wait_timeout = 28800000

In windows, add the following content in my. ini:

Interactive_timeout = 28800000

Wait_timeout = 28800000

BitsCN.com

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.