the global interactive_timeout value depending on the type of client (as defined by the CLIENT_INTERACTIVE connect option to mysql _real_connect()). MySQL 大拿Jeremy Zawodny曾在他的文章Fixing Poor MySQL Default Configuration Values里面列出了几个很恶心的MySQL 缺省设置,不过没包含wait_timeout,但我觉得它也应该算一个,每次新装MySQL 后最好都记得修改它。 以上的修改配置来源网页 : mysql >show variables like '%timeout';打印结果如下:+----------------------------+-------+| Variable_name | Value |+----------------------------+-------+| connect_timeout | 5 || delayed_insert_timeout | 300 || interactive_timeout | || net_read_timeout | 30 || net_write_timeout | 60 || slave_net_timeout | 3600 || wait_timeout | |+----------------------------+-------+ interactive_timeout 需在mysql _connect()设置CLIENT_INTERACTIVE选项后起作用,并被赋值为wait_timeout;mysql >set wait_timeout = 10; 对当前交互链接有效 ;mysql >set interactive_timeout = 10; 对后续起的交互链接有效; 该超时时间单位是秒,从变量从上次SQL执行后算起;当前空闲若超过该时间,则也会被强制断开。 想把mysql 的连接断开时间改长一些,以前只改了connect_timeout变量的值,还不够。现在又改了这两个,不知够不够。不够再继续查吧。注意:对两个值都做修改才升效:set interactive_timeout=120; set wait_timeout=120;mysql > show variables like '%timeout';+-------------------------+-------+| Variable_name | Value |+-------------------------+-------+| connect_timeout | 5 || delayed_insert_timeout | 300 || interactive_timeout | || net_read_timeout | 30 || net_write_timeout | 60 || slave_net_timeout | 3600 || table_lock_wait_timeout | 50 || wait_timeout | |+-------------------------+-------+mysql > set interactive_timeout=120; set wait_timeout=120;Query OK 0 rows affected (0.00 sec) mysql > show variables like '%timeout';+-------------------------+-------+| Variable_name | Value |+-------------------------+-------+| connect_timeout | 5 || delayed_insert_timeout | 300 || interactive_timeout | 120 || net_read_timeout | 30 || net_write_timeout | 60 || slave_net_timeout | 3600 || table_lock_wait_timeout | 50 || wait_timeout | 120 |+-------------------------+-------+ 修改全局变量:set global interactive_timeout=120;set global wait_timeout=120;mysql > show global variables like '%timeout';+-------------------------+-------+| Variable_name | Value |+-------------------------+-------+| connect_timeout | 5 || delayed_insert_timeout | 300 || interactive_timeout | 120 || net_read_timeout | 30 || net_write_timeout | 60 || slave_net_timeout | 3600 || table_lock_wait_timeout | 50 || wait_timeout | 120 |+-------------------------+-------+ 特别注意全局和一般变量时不一样的两个变量,这也就是为何导致修改没有起作用的原因!!!! 配置修改:直接的修改 /etc/my.cnf这个文件中 -------------------------------------------[mysqld] wait_timeout = interactive_timeout = --------------------------------------------添加这两行,然后重新启动mys