From:http://dba.stackexchange.com/questions/1558/how-long-is-too-long-for-mysql-connections-to-sleep

I logged onto my server to check the status of the database and noticed on the SHOW PROCESSLIST;that there are a large number of connections sleeping that are very old.

What duration should the connection time limit be before the connection should be killed?

How do I set the time limit in MySQL 5.0.51a-3ubuntu5.4?

Note:

I am using PHP 5.2.x and symfony framework 1.2.

asked Mar 3 '11 at 20:37
Patrick

1,46461625
 

mysqld will timeout DB Connections based on two(2) server options:

  • interactive_timeout
  • wait_timetout

Both are 28800 seconds (8 hours) by default.

You can set these options in /etc/my.cnf

If your connections are persistent (opened via mysql_pconnect) you could lower these numbers to something reasonable like 600 (10 min) or even 60 (1 min). Or, if your app works just fine, you can leave the default. This is up to you.

You must set these as follows in my.cnf (takes effect after mysql restart):

[mysqld]
interactive_timeout=180
wait_timeout=180

If you do not want to restart mysql, then run these two commands:

SET GLOBAL interactive_timeout = 180;
SET GLOBAL wait_timeout = 180;

This will not close the connections already open. This will cause new connections to close in 180 sec.

answered Mar 3 '11 at 21:22
RolandoMySQLDBA

103k14132264
 
    
so in /etc/my.cnf I would just put wait_timeout=180? – Patrick Mar 3 '11 at 22:28
    
@Patrick Yes, but you need to set both interactive_timeout and wait_timeout to 180. I updated my answer for your response. – RolandoMySQLDBA Mar 3 '11 at 22:29 
    
This file can be elsewhere dev.mysql.com/doc/refman/5.1/en/option-files.html and these options may not be explicited (write them by yourself) – nicolallias Jun 15 '15 at 15:33

【转载】How long is “too long” for MySQL Connections to sleep?的更多相关文章

  1. 【转载】 使用Anemometer基于pt-query-digest将MySQL慢查询可视化

    原文地址:使用Anemometer基于pt-query-digest将MySQL慢查询可视化 作者:84223932 本文主要介绍使用Anemometer基于pt-query-digest将MySQL ...

  2. 转载---Beats:如何使用Filebeat将MySQL日志发送到Elasticsearch

    在今天的文章中,我们来详细地描述如果使用Filebeat把MySQL的日志信息传输到Elasticsearch中.为了说明问题的方便,我们的测试系统的配置是这样的: 我有一台MacOS机器.在上面我安 ...

  3. 转载:centos7下使用yum安装mysql

    转自:http://www.cnblogs.com/hwd-cnblogs/p/5213337.html CentOS7的yum源中默认好像是没有mysql的.为了解决这个问题,我们要先下载mysql ...

  4. [转载] 运维角度浅谈:MySQL数据库优化

    一个成熟的数据库架构并不是一开始设计就具备高可用.高伸缩等特性的,它是随着用户量的增加,基础架构才逐渐完善. 作者:zhenliang8,本文转自51CTO博客,http://lizhenliang. ...

  5. 【转载】MyBatis JdbcType 与Oracle、MySql数据类型对应关系详解

    [原文链接]:MyBatis JdbcType 与Oracle.MySql数据类型对应关系详解 1. Mybatis JdbcType与Oracle.MySql数据类型对应列表 2. Mybatis ...

  6. mysql connections

    在使用MySQL数据库的时候,经常会遇到这么一个问题,就是“Can not connect to MySQL server. Too many connections”-mysql 1040错误,这是 ...

  7. (转载)Mysql查找如何判断字段是否包含某个字符串

    (转载)http://www.th7.cn/db/mysql/201306/31159.shtml 有这样一个需求,在Mysql数据库字符串字段(权限)中,用户有多个不同的邮箱,分别被‘,’分开,现在 ...

  8. (转载)mysql中百万级数据插入速度测试

    (转载)http://www.111cn.net/database/mysql/42453.htm 100W的数据对于很多朋友来说算小菜了,但今天我就想到创建一个大量数据的测试环境,于是找了一下怎么插 ...

  9. MYSQL 50 基础题 (转载)

    MYSQL 50 基础题 (转载) 前言:最近在强化MYSQL 能力 答案在(也是转载处) https://www.cnblogs.com/kangxinxin/p/11585935.html 下面是 ...

随机推荐

  1. MongoDB从环境搭建到代码编程(Window 环境)

    本人开发环境: window Server 2008 , 64位系统 服务端 MongoDB下载地址:http://www.mongodb.org/downloads  (本人己下好的在百度网盘 : ...

  2. P1331 海战

    P1331 海战 题目描述 在峰会期间,武装部队得处于高度戒备.警察将监视每一条大街,军队将保卫建筑物,领空将布满了F-2003飞机.此外,巡洋船只和舰队将被派去保护海岸线.不幸的是因为种种原因,国防 ...

  3. win10 无法修改默认程序 默认打开方式的解决方法

    此时是2018年11月24日 win10 pro 64位 版本是1803  具体版本号是17134 情景: 我的状况是.json文件的默认打开方式被新安装的应用霸占了,然后无论是通过“右键-属性-更改 ...

  4. Qt用委托绘制需要的图形的步骤

    1.拷贝一份option: QStyleOptionViewItemV4 opt = option; 2.获取到widget,也是通过QStyleOptionViewItem &option ...

  5. 通过repcached实现memcached主从复制

    一.环境 服务器A:ubuntu server 12.04(192.168.1.111) 服务器B:ubuntu server 12.04 (47.50.13.111) 二.memcached安装 s ...

  6. 小议Android多进程以致Application多次初始化

    最近遇到一个bug,当应用加了多进程后,比如总共进程数为N,会出现在`startService()`时`onStartCommand()`方法会被重复调用`(N-1)`次的奇怪现象. ***## 祸起 ...

  7. 名片管理系统demo

    # 定义一个列表,用来储存名片 def cardInfors(): # 打印功能提示 print('欢迎使用名片管理系统v6.6.6') print('1:添加一个名片') print('2:删除一个 ...

  8. Java判断数字的奇偶

    package anli; import java.util.Scanner; public class jiou { public static void main(String[] args){ ...

  9. 软工实践 - 第二十六次作业 Beta 冲刺(4/7)

    队名:起床一起肝活队 组长博客:https://www.cnblogs.com/dawnduck/p/10124816.html 作业博客:班级博客本次作业的链接 组员情况 组员1(队长):白晨曦 过 ...

  10. ssh问题_1

    昨天配置了虚拟机的ssh,可以相互连接,但是今天早上就不行了,遇到如下错误 [slave1@hadoop ~]$ scp .ssh/id_rsa.pub master@hadoop.master:~/ ...