Get the App
SLTechnology News&Howtos  ›  Database  › 

The difference and explanation of two parameters related to MySQL connection timeout: interactive_timeout and wait_timeout

Shulou Source: shulou.com Published: 2022-05-31 18:38:58 09月11日 Update

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!

Tags: Interactive two parameters interpretation data database content variables time learning practical deeper straightforward global interest function unit official practical practical Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei macOS Apple Linux Shulou Tech Info