您的位置:首页 > 运维架构 > Linux

Linux下mysql修改连接超时(windows下也适用)

2013-12-13 16:13 513 查看
首先进入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,修改好了

引用地址:http://www.2cto.com/database/201304/206742.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: