Linux下mysql修改连接超时wait_timeout
2016-06-01 09:55:25
首先:show variables like '%timeout%';
显示结果:+----------------------------+----------+
| Variable_name | Value |
+----------------------------+----------+
| connect_timeout | 10 |
| delayed_insert_timeout | 300 |
| innodb_lock_wait_timeout | 50 |
| innodb_rollback_on_timeout | OFF |
| interactive_timeout | 28800 |
| lock_wait_timeout | 31536000 |
| net_read_timeout | 30 |
| net_write_timeout | 60 |
| slave_net_timeout | 3600 |
| wait_timeout | 28800 |
+----------------------------+----------+
其中有用的是: interactive_timeout 和wait_timeout 为28800,默认为8小时设置;
一般线上的环境中mysql中连接时间设置为7天即可;
其次:执行命令:set interactive_timeout=604800;
set wait_timeout=604800;
最后:执行show variables like '%timeout%';看看执行成功没有,显示结果为:
+----------------------------+----------+
| Variable_name | Value |
+----------------------------+----------+
| connect_timeout | 10 |
| delayed_insert_timeout | 300 |
| innodb_lock_wait_timeout | 50 |
| innodb_rollback_on_timeout | OFF |
| interactive_timeout | 604800 |
| lock_wait_timeout | 31536000 |
| net_read_timeout | 30 |
| net_write_timeout | 60 |
| slave_net_timeout | 3600 |
| wait_timeout | 604800 |
+----------------------------+----------+
表明执行成功了。。。