用PHP删除MySQL死连接
PHP #mysql #死连接2014-04-15 22:51
下面是用PHP来删除MYSQL死连接(Sleep)的方法。
<?php
define('MAX_SLEEP_TIME', 120);
$hostname = "localhost";
$username = "yige";
$password = "http://yige.org/php/";
$connect = mysql_connect($hostname, $username, $password);
$result = mysql_query("SHOW PROCESSLIST", $connect);
while ($proc = mysql_fetch_assoc($result)) {
if ($proc["Command"] == "Sleep" && $proc["Time"] > MAX_SLEEP_TIME) {
@mysql_query("KILL " . $proc["Id"], $connect);
}
}
mysql_close($connect);相关文章
- PHP查看内存的使用信息 2014/04/15
- PHP查看CPU的使用信息 2014/04/15
- 配置Apache服务器的PHP错误提示 2014/04/15
- PHP给XML添加数据 2014/04/15
- PHP生成随机字符串的函数 2014/04/15
- PHP生成随机密码的函数 2014/04/14
- PHP计算时间差的方法 2014/04/13
- PHP的SQL注入式攻击介绍 2014/04/13
- php过滤危险html的代码 2014/04/13
- PHP获取文件大小的方法 2014/04/13