Home > Database > Mysql Tutorial > body text

MySQL - Detailed explanation of the server maintaining connection with MySQL (picture)

黄舟
Release: 2017-03-10 11:02:51
Original
1044 people have browsed it

Server programs often need to access the database, and the server program keeps running for a long time. Mysql has a feature. It does not do any operations after connecting to the database. By default, it will automatically close the dormant connection after 8 hours! Under normal circumstances, it is difficult to predict when the program will perform database operations. If the connection is disconnected by MySQL, unexpected problems will occur. This is a disaster in server programs! One way to maintain the connection between the server program and MySQL is to modify the default sleep time, but this method treats the symptoms but not the root cause; the other way is obviously to regularly perform database operations to maintain the connection to MySQL.

How to check the default sleep time:

After logging in to mysql, enter the command show variables like '%timeout%', and some variables about sleep timeout in mysql will appear


The wait_timeout variable is 28800, which is 28800 seconds, which is the default 8 hours;

To check the connection status, use the show processlist command

The Time field indicates the time of the current connection. By default, when no operations are performed for a long time, the Time field value will increase with time. When it is greater than 28800 seconds, it will Close the current connection; on the contrary, if a database operation is performed within the default 8 hours, the time will start from 0.


The above is the detailed content of MySQL - Detailed explanation of the server maintaining connection with MySQL (picture). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!