使用 show status 确定 MySQL 中的活动连接或总连接
运行“show status like 'Con%'”时,它会显示代表连接的数字。但问题来了:这是活跃连接数还是累计总数?
根据 MySQL 文档,它指的是整个历史的连接总数:
"Connections
尝试连接 MySQL 服务器的次数(成功与否)。"
确定连接的次数活动连接,请考虑使用以下方法之一:
Threads_connected 状态变量:
"Threads_connected
当前打开的数量连接。”
示例:
mysql> show status where `variable_name` = 'Threads_connected'; +-------------------+-------+ | Variable_name | Value | +-------------------+-------+ | Threads_connected | 4 | +-------------------+-------+ 1 row in set (0.00 sec)
显示进程列表命令:
mysql> show processlist; +----+------+-----------------+--------+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------------+--------+---------+------+-------+------------------+ | 3 | root | localhost | webapp | Query | 0 | NULL | show processlist | | 5 | root | localhost:61704 | webapp | Sleep | 208 | | NULL | | 6 | root | localhost:61705 | webapp | Sleep | 208 | | NULL | | 7 | root | localhost:61706 | webapp | Sleep | 208 | | NULL | +----+------+-----------------+--------+---------+------+-------+------------------+ 4 rows in set (0.00 sec)
以上是'show status like 'Con%'”显示的是活动连接还是总连接数?的详细内容。更多信息请关注PHP中文网其他相关文章!