MySQL如何查询客户端连接情况
目录
- mysql查询客户端连接情况
- 查询MySQL当前所有连接及状态
- 查询MySQL当前连接IP、状态及连接数量
- 查询MySQL当前连接IP及其连接数量
- 查询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 | | python 2 | | localhost | executing | 1 | +-----------------+-----------+----------+ 2 rows in set (0.00 sec)
查询MySQL当前连接IP及其http://www.devze.com连接数量
mysql> SELECT substring_index(host, ':', 1) AS ip, count(*) FROM information_schema.processlist GROUP BY ip; +-----------------+----------+ | ip | count(*) | +-----------------+-------www.devze.com---+ | 183.192.226.255 | 2 | | localhttp://www.devze.comhost | 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 sejavascriptc)
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程客栈(www.devze.com)。
精彩评论