天天看点

mysql 长链接 sleep_mysql sleep连接过多解决办法_mysql

mysql sleep连接过多解决方法

1。vim /etc/my.cnf

在[mysqld]中添加设置为:

interactive_timeout=80

wait_timeout=80

添加修改好后重启数据库: /etc/init.d/mysql restart

这种方式比较直接。

2.mysql>show variables like '%timeout';

打印结果如下:

+----------------------------+-------+

| Variable_name | Value |

+----------------------------+-------+

| connect_timeout | 5 |

| delayed_insert_timeout | 300 |

| interactive_timeout | 28800 |

| net_read_timeout | 30 |

| net_write_timeout | 60 |

| slave_net_timeout | 3600 |

| wait_timeout | 28800 |

+----------------------------+-------+

interactive_timeout 需在mysql_connect()设置CLIENT_INTERACTIVE选项后起作用,并被赋值为wait_timeout;

mysql>set wait_timeout = 10; 对当前交互链接有效;

mysql>set interactive_timeout = 10; 对后续起的交互链接有效;

该超时时间单位是秒,从变量从上次SQL执行后算起;当前空闲若超过该时间,则也会被强制断开。

欢迎大家阅读《mysql sleep连接过多解决办法_mysql》,跪求各位点评,by 搞代码

mysql 长链接 sleep_mysql sleep连接过多解决办法_mysql

微信 赏一包辣条吧~

mysql 长链接 sleep_mysql sleep连接过多解决办法_mysql

支付宝 赏一听可乐吧~