正如Riedsio所述,连接后会话变量不会改变,除非您专门设置它们;设置全局变量只会改变下一个连接的会话值。
例如,如果您有100个连接,并且您降低全局wait_timeout
那么它不会影响现有连接,只会在变量发生更改后新连接。
特别是对于wait_timeout
变量,有一个转折点。 如果您使用的是mysql
客户端的交互方式,或者用CLIENT_INTERACTIVE
连接器通过mysql_real_connect()
设置,那么您将看到@@session.wait_timeout
这里interactive_timeout
集,你可以看到这个证明:
> ./bin/mysql -Bsse 'select @@session.wait_timeout, @@session.interactive_timeout, @@global.wait_timeout, @@global.interactive_timeout'
70 60 70 60
> ./bin/mysql -Bsse 'select @@wait_timeout'
70
> ./bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.7.12-5 MySQL Community Server (GPL)
Copyright (c) 2009-2016 Percona LLC and/or its affiliates
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select @@wait_timeout;
+----------------+
| @@wait_timeout |
+----------------+
| 60 |
+----------------+
1 row in set (0.00 sec)
所以,如果您使用客户端进行测试,那么您将在连接时看到的是interactive_timeout
,而不是wait_timeout
的值
来源
2016-06-21 11:38:02
Cez
您的回答直接与OP相矛盾,并且您没有解决矛盾。 – klaar 2016-01-05 09:49:57