Troubleshooting of MySQL query timeout

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.