-
查看进程列表:
show processlist;
Sleep表示当前有一个空闲连接mysql> show processlist; +----+------+-----------------+----------+---------+------+----------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------------+----------+---------+------+----------+------------------+ | 34 | root | localhost:62974 | NULL | Query | 0 | starting | show processlist | | 35 | root | localhost:62979 | cmsdbdev | Sleep | 2 | | NULL | +----+------+-----------------+----------+---------+------+----------+------------------+ 2 rows in set (0.00 sec)
-
查看参数:
show variables like 'wait%';
等待超时时间默认是8小时,超过此值客户端就会被断开mysql> show variables like 'wait%'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | wait_timeout | 28800 | +---------------+-------+ 1 row in set, 1 warning (0.00 sec)
-
修改参数:
set wait_timeout = 60;
修改变量的值- 默认修改的参数只对当前会话起作用,相当于
set SESSION
- 如果需要修改全局,使用
set GLOBAL
mysql> set wait_timeout = 60; Query OK, 0 rows affected (0.00 sec) mysql> show variables like 'wait%'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | wait_timeout | 60 | +---------------+-------+ 1 row in set, 1 warning (0.00 sec) ## 全局修改,对当前会话不起作用,对新创建的会话起作用 mysql> set GLOBAL wait_timeout = 60; Query OK, 0 rows affected (0.00 sec) mysql> show variables like 'wait%'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | wait_timeout | 28800 | +---------------+-------+ 1 row in set, 1 warning (0.00 sec) ## 重新打开一个会话
超过一分钟后,再次查询,报错了:
mysql> show variables like 'wait%'; ERROR 2013 (HY000): Lost connection to MySQL server during query
- 默认修改的参数只对当前会话起作用,相当于