标签:

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,修改好了

标签:

GitHub 加速计划 / li / linux-dash
13
2
下载
A beautiful web dashboard for Linux
最近提交(Master分支:4 个月前 )
186a802e added ecosystem file for PM2 5 年前
5def40a3 Add host customization support for the NodeJS version 5 年前
Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐