mysql set wait_timeout 的命令行实现

mysql> show variables like 'wait_timeout';
Jeremy> +---------------+-------+
Jeremy> | Variable_name | Value |
Jeremy> +---------------+-------+
Jeremy> | wait_timeout | 28800 |
Jeremy> +---------------+-------+
Jeremy> 1 row in set (0.00 sec)

mysql> set global wait_timeout=60;
Jeremy> Query OK, 0 rows affected (0.00 sec)

mysql> show variables like 'wait_timeout';
Jeremy> +---------------+-------+
Jeremy> | Variable_name | Value |
Jeremy> +---------------+-------+
Jeremy> | wait_timeout | 28800 |
Jeremy> +---------------+-------+
Jeremy> 1 row in set (0.00 sec)

Jeremy> How-to-repeat: just run those commands.

The above is correct. In the last query you are looking at the thread
specific variable, not the startup variable.

To repeat:

mysql> show global variables like 'wait_timeout';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout | 28800 |
+---------------+-------+
1 row in set (0.00 sec)

mysql> set global wait_timeout=60;
Query OK, 0 rows affected (0.00 sec)

mysql> show global variables like 'wait_timeout';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout | 60 |
+---------------+-------+
1 row in set (0.00 sec)

And with the alternative syntax:

mysql> set @@session.wait_timeout=70;
Query OK, 0 rows affected (0.00 sec)

mysql> select @@session.wait_timeout,@@global.wait_timeout;
+----------------+----------------+
| @@wait_timeout | @@wait_timeout |
+----------------+----------------+
| 70 | 60 |
+----------------+----------------+
1 row in set (0.00 sec)

In other words, you have two variables, 'session.wait_timeout'
andd 'global.wait_timeout' that can be set independently.

你可能感兴趣的:(thread,mysql)