Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The usage of mysql timeout parameter

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "the usage of mysql timeout parameters". In daily operation, I believe many people have doubts about the usage of mysql timeout parameters. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "the usage of mysql timeout parameters"! Next, please follow the editor to study!

Wait_timeout is the variable responsible for timeout control, and its time is 28800s, that is, 8 hours, so the service of MySQL will be disconnected after the operation interval of 8 hours and need to be reconnected. There are also users who use jdbc.url=jdbc:mysql://localhost:3306/nd?autoReconnect=true in URL to automatically restore the connection, of course, this is possible, but it is applicable to MySQL4 and below. It is no longer valid in MySQL5 and the system variable must be adjusted to control it. The two variables are described in the MySQL5 manual as follows:

Interactive_timeout: the number of seconds the server waits for activity before closing the interactive connection. An interactive client is defined as a client that uses the CLIENT_INTERACTIVE option in mysql_real_connect (). See wait_timeout again.

Wait_timeout: the number of seconds the server waits for activity before closing a non-interactive connection. When a thread starts, the session wait_ timeout value is initialized based on the global wait_ timeout value or the global interactive_ timeout value, depending on the client type (defined by the connection option CLIENT_INTERACTIVE of mysql_real_connect ()), see also interactive_timeout

In this way, the two variables are jointly controlled, so both of them must be modified. To go further, the values of the two variables wait_timeout range from 1 to 2147483 (Windows) and 1 to 31536000 (linux). The values of interactive_time vary with wait_timeout, and their default values are 28800.

The system variable of MySQL is controlled by the configuration file, and when it is not configured in the configuration file, the system uses the default value, which is 28800. If you want to modify it, you can only modify it in the configuration file. There is a mysql.ini configuration file under% MySQL HOME%/bin under Windows. After opening it, add two variables and assign values in the following location. (here it is changed to 388000)

Save exit, restart the mysql service, must be to restart the system service. You can see the result of the modification:

At this point, the study of "the usage of mysql timeout parameters" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report