MySQL--server keep a connection to MySQL

Source: Internet
Author: User
Reprint Please specify source: http://blog.csdn.net/l1028386804/article/details/47008019

Server programs often have access to the database, and the server program is kept running for a long time, and MySQL has a feature. When you connect to a database and do nothing, the default is to turn off the dormant connection on your own by 8 hours. Under normal circumstances it is very difficult to predict when the program will run database operations. If the connection is disconnected by MySQL, an unexpected problem will occur. This is a disaster in the server program!

One way to keep the server program connected to MySQL is to change the default sleep time, but in such a way it is not a cure; there is also a very obvious way to run database operations regularly to keep a connection to MySQL.

To see how the default sleep time is:

Log in to MySQL after entering the command show variables like '%timeout% ' will appear in MySQL some variables about the sleep timeout

The wait_timeout variable is 28800, that is, 28,800 seconds, also is the default of 8 hours;

View connection status. Using the show processlist command

The Time field indicates when the current connection is made, by default. When not doing anything for a long time. The time field value increases over the duration of 28,800 seconds and the current connection is closed; Within 8 hours of this default. Assuming the database operation is running, it will start at 0.

MySQL--server keep a connection to MySQL

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.