当前位置: 代码网 > it编程>数据库>Mysql > MySQL如何查询客户端连接情况

MySQL如何查询客户端连接情况

2024年08月19日 Mysql 我要评论
mysql查询客户端连接情况查询mysql当前所有连接及状态mysql> select host, state from information_schema.processlist;+----

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)

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com