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 difference and explanation of two parameters related to MySQL connection timeout: interactive_timeout and wait_timeout

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly explains "the difference and explanation of the two parameters interactive_timeout and wait_timeout related to MySQL connection timeout". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the difference and explanation of the two parameters interactive_timeout and wait_timeout related to MySQL connection timeout.

Let's first take a look at the definition of these two parameters in the official documentation.

Interactive_timeout

The default is 28800, in seconds, or 8 hours.

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.

Wait_timeout

The default is also 28800s.

The number of seconds the server waits for activity on a noninteractive connection before closing it.

On thread startup, the session wait_timeout value is initialized from the global wait_timeout value or from the global interactive_timeout value, depending on the type of client (as defined by the CLIENT_INTERACTIVE connect option to mysql_real_connect ()). See also interactive_timeout.

Interactive_timeout is for interactive connections and wait_timeout is for non-interactive connections. The so-called interactive connection means that the CLIENT_INTERACTIVE option is used in the mysql_real_connect () function.

To put it bluntly, connecting to the database through the mysql client is an interactive connection, while connecting to the database through jdbc is a non-interactive connection.

Interactive_timeout: interactive connection timeout (mysql tool, mysqldump, etc.)

Wait_timeout: non-interactive connection timeout, default connection mysql api program, jdbc connection database, etc.

When the connection starts, confirm whether the value of the session variable wait_timeout inherits from the global variable wait_timeout or interactive_timeout based on the type of connection.

How to set up and view:

Mysql > set global interactive_timeout=1800

Query OK, 0 rows affected (0.00 sec)

Mysql > set global wait_timeout=1800

Query OK, 0 rows affected (0.00 sec)

Mysql > show global variables like 'interactive_timeout'

+-+ +

| | Variable_name | Value |

+-+ +

| | interactive_timeout | 1800 | |

+-+ +

1 row in set (0.00 sec)

Mysql > show global variables like 'wait_timeout'

+-+ +

| | Variable_name | Value |

+-+ +

| | wait_timeout | 1800 | |

+-+ +

1 row in set (0.00 sec)

At this point, I believe you have a deeper understanding of the difference and explanation of the two parameters interactive_timeout and wait_timeout related to the MySQL connection timeout. You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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

Wechat

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

12
Report