In mysql, we need to set the mysql database query and connection timeout time. We only need to modify the wait_timeout value. There are two ways to modify the wait_timeout value, one is to use cmd to modify the value, the other is in mysql my. modify the cnf configuration file. First open your MySql console, enter the password, and then enter the command to quietly why the SQL Code times out and copies the content to the clipboard
- Show global variables like 'wait _ timeout ';
Here we can see that wait_timeout is 28800, which is 8 hours. That is to say, the MySQL service will be disconnected after 8 hours of operation, and re-connection is required. When we connect to java program JDBC, we can make it automatically restored.
Interactive_timeout: The number of seconds before the server closes the interactive connection. Interactive clients are defined as clients that use the CLIENT_INTERACTIVE option in mysql_real_connect. For more information, see wait_timeout.
Wait_timeout: The number of seconds before the server closes a non-interactive connection. When a thread starts, the wait_timeout value of the session 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 interactive_timeout.
In this case, the two variables are jointly controlled and must be modified. The value range of wait_timeout is 1-2147483 (Windows), 1-31536000 (linux), and interactive_time varies with wait_timeout. Their default values are 28800.
MySQL System variables are controlled by the configuration file. If the configuration file is not configured, the system uses the default value. The default value is 28800. You can only modify it in the configuration file. In Windows, the my. ini configuration file exists in % MySQL HOME %. After opening the file, add the following sentence. (Change to 388000 here) Save and quit. Restart the mysql service. It must be a restart of the system service. The Modification result is displayed: the configuration file in Linux is/etc/my. cnf. (Same as above)