Linux下mysql修改连接超时

1,首先进入mysql,查看 wait_timeout、interactive_timeout这个值是否为默认的8小时(即 28800)
[root@server110 ~]# mysql -u root -p
Enter password:
输密码进入
执行如下命令
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 |
| net_read_timeout           | 30    |
| net_write_timeout          | 60    |
| slave_net_timeout          | 3600  |
| table_lock_wait_timeout    | 50    |
| wait_timeout               | 28800 |
+----------------------------+-------+
如下表所示,说明连接超时时间使用的是默认的8小时
修改之
2.在mysql 5以上的版本需要修改my.cnf这个文件,这个文件的位置在
/etc/my.cnf
在[mysqld]后面加上如下两句话
wait_timeout=388000
interactive_timeout=388000
3.下面重启下mysql
service mysqld restart
显示如下内容
停止 MySQL:                                               [确定]
启动 MySQL:                                               [确定]
现在你可以在用1的方法,查看下这两个参数的值
+----------------------------+--------+
| Variable_name              | Value  |
+----------------------------+--------+
| connect_timeout            | 10     |
| delayed_insert_timeout     | 300    |
| innodb_lock_wait_timeout   | 50     |
| innodb_rollback_on_timeout | OFF    |
| interactive_timeout        | 388000 |
| net_read_timeout           | 30     |
| net_write_timeout          | 60     |
| slave_net_timeout          | 3600   |
| table_lock_wait_timeout    | 50     |
| wait_timeout               | 388000 |
+----------------------------+--------+
OK,修改好了

猜你喜欢

转载自chenjinbo1983.iteye.com/blog/1852710