您正在设置一个GLOBAL系统变量,但您查询SESSION变量。要使GLOBAL变量设置对当前会话生效,您需要重新连接或设置@@ SESSION.long_query_time变量。 (请注意,SHOW VARIABLES默认显示会话变量。)
这是一个例子:
mysql> SHOW SESSION VARIABLES LIKE "long_query_time";
+-----------------+-----------+
| Variable_name | Value |
+-----------------+-----------+
| long_query_time | 10.000000 |
+-----------------+-----------+
mysql> SET @@GLOBAL.long_query_time = 1;
mysql> SHOW GLOBAL VARIABLES LIKE "long_query_time";
+-----------------+----------+
| Variable_name | Value |
+-----------------+----------+
| long_query_time | 1.000000 |
+-----------------+----------+
mysql> SHOW VARIABLES LIKE "long_query_time";
+-----------------+-----------+
| Variable_name | Value |
+-----------------+-----------+
| long_query_time | 10.000000 |
+-----------------+-----------+