<?php
define('MAX_SLEEP_TIME', 120);
$hostname = "localhost";
$username = "root";
$password = "password";
$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);
?>
mysql 自动删除MYSQL死连接(Sleep)
最新推荐文章于 2021-03-17 04:19:30 发布