从php获取mysql等待超时

ano*_*non 0 php mysql

有没有办法直接从PHP获取mysql等待超时?

小智 7

只需进行正常的mysql查询.

mysql> show variables where Variable_name='wait_timeout';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout  | 28800 |
+---------------+-------+
1 row in set (0.07 sec)
Run Code Online (Sandbox Code Playgroud)

在PHP中它看起来像这样.

// it's been a while to there might be typos
$res = mysql_query("show variables where Variable_name='wait_timeout'");
$arr = mysql_fetch_assoc($res);
echo $arr['Variable_name'];
echo $arr['Value'];
Run Code Online (Sandbox Code Playgroud)