Troubleshooting of MySQL query timeout

Source: Internet
Author: User
Tags mysql command line

What is the cause of MySQL query timeout? What should we do? The following describes how to solve the MySQL query timeout problem in detail.

 
 
  1. mysql>show variables like '%timeout';   
  2.  

The output is as follows:

 
 
  1. +----------------------------+-------+   
  2. | Variable_name | Value |   
  3. +----------------------------+-------+   
  4. | connect_timeout | 5 |   
  5. | delayed_insert_timeout | 300 |   
  6. | interactive_timeout | 28800 |   
  7. | net_read_timeout | 30 |   
  8. | net_write_timeout | 60 |   
  9. | slave_net_timeout | 3600 |   
  10. | wait_timeout | 28800 |   
  11. +----------------------------+-------+   
  12.  

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.

Interactive_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:

 
 
  1. // Enable MYSQL_CLIENT_INTERACTIVE mode to connect to the Database Server
  2.  
  3. $ Link = mysql_connect ($ host, $ user, $ pwd, false, MYSQL_CLIENT_INTERACTIVE );
  4.  

How to adjust the MySQL Query Buffer

How MySQL query optimizer works

In-depth parsing of MySQL query Cache Mechanism

Common MySQL command line tools

Implementation of MySQL non-repeated Query

Related Article

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.