Sometimes we may encounter a MySQL query timeout problem. The following describes how to solve the MySQL query timeout problem for your reference.
Mysql> show variables like '% timeout ';
The output is as follows:
+ ---------------------------- + ------- +
| Variable_name | Value |
+ ---------------------------- + ------- +
| Connect_timeout | 5 |
| Delayed_insert_timeout | 300 |
| Interactive_timeout | 28800 |
| Net_read_timeout | 30 |
| Net_write_timeout | 60 |
| Slave_net_timeout | 3600 |
| Wait_timeout | 28800 |
+ ---------------------------- + ------- +
Interactive_timeout takes effect after the CLIENT_INTERACTIVE option is set in mysql_connect () and is assigned as wait_timeout;
Mysql> set wait_timeout = 10; valid for the current interactive link;
Mysql> set interactive_timeout = 10; valid for subsequent interaction links;
The timeout time is measured in seconds and starts from the time after the last SQL statement is executed. If the current idle time exceeds this time, the variable is forcibly disconnected.
Nteractive_timeout (commonly used)
The number of seconds the server waits for activity on an interactive connection before closing it. An interactive client is defined as a client that uses the CLIENT_INTERACTIVE option to mysql_real_connect (). See also wait_timeout.
Translation: idle timeout time for client-server interaction. This system variable takes effect only when the "MYSQL_CLIENT_INTERACTIVE" flag is set when the client connects to the server. For example:
/Enable MYSQL_CLIENT_INTERACTIVE mode to connect to the Database Server
$ Link = mysql_connect ($ host, $ user, $ pwd, false, MYSQL_CLIENT_INTERACTIVE );
The preceding section describes the troubleshooting methods for MySQL query timeout.
About MySQL query Cache Mechanism
Use MySQL Union to avoid sequential Storage
Five common MySQL Log types
Mysql bin log files clear sh instances
Mysql Log File description