MySQL如何查询客户端连接情况
作者:达希_
这篇文章主要介绍了MySQL如何查询客户端连接情况,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教
MySQL查询客户端连接情况
查询MySQL当前所有连接及状态
mysql> SELECT host, state FROM information_schema.processlist; +----------------------+-----------+ | host | state | +----------------------+-----------+ | localhost | executing | | 183.192.226.255:1842 | | | 183.192.226.255:1841 | | +----------------------+-----------+ 3 rows in set (0.00 sec)
查询MySQL当前连接IP、状态及连接数量
mysql> SELECT substring_index(host, ':', 1) AS ip, state, count(*) FROM information_schema.processlist GROUP BY ip, state; +-----------------+-----------+----------+ | ip | state | count(*) | +-----------------+-----------+----------+ | 183.192.226.255 | | 2 | | localhost | executing | 1 | +-----------------+-----------+----------+ 2 rows in set (0.00 sec)
查询MySQL当前连接IP及其连接数量
mysql> SELECT substring_index(host, ':', 1) AS ip, count(*) FROM information_schema.processlist GROUP BY ip; +-----------------+----------+ | ip | count(*) | +-----------------+----------+ | 183.192.226.255 | 2 | | localhost | 1 | +-----------------+----------+ 2 rows in set (0.01 sec)
查询MySQL最大连接数
mysql> show variables like 'max_connections'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 600 | +-----------------+-------+ 1 row in set (0.01 sec)
查询MySQL当前连接数
mysql> show status like 'max_used_connections'; +----------------------+-------+ | Variable_name | Value | +----------------------+-------+ | Max_used_connections | 17 | +----------------------+-------+ 1 row in set (0.00 sec)
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。