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