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)
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论