Mysql查看连接数相关信息

Posted zhzhang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mysql查看连接数相关信息相关的知识,希望对你有一定的参考价值。

mysql查看连接数相关信息在

数据库:INFORMATION_SCHEMA
表:PROCESSLIST

表结构如下:

mysql> desc PROCESSLIST;
+---------+-------------+------+-----+---------+-------+
| Field   | Type        | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| ID      | bigint(4)   | NO   |     | 0       |       |
| USER    | varchar(16) | NO   |     |         |       |
| HOST    | varchar(64) | NO   |     |         |       |
| DB      | varchar(64) | YES  |     | NULL    |       |
| COMMAND | varchar(16) | NO   |     |         |       |
| TIME    | int(7)      | NO   |     | 0       |       |
| STATE   | varchar(64) | YES  |     | NULL    |       |
| INFO    | longtext    | YES  |     | NULL    |       |
+---------+-------------+------+-----+---------+-------+
8 rows in set (0.00 sec)

 

查看单个host连接数:

select 
  substring_index(host,":",1) as host, count(1) as cnt
from (select * from INFORMATION_SCHEMA.PROCESSLIST) a
group by
  substring_index(host,":",1) order by cnt desc;

查看db连接数:

select db,count(1) as cnt from INFORMATION_SCHEMA.PROCESSLIST group by db order by cnt desc;

 





以上是关于Mysql查看连接数相关信息的主要内容,如果未能解决你的问题,请参考以下文章

MySQL的连接数

查看MySQL实例的当前连接数

怎么查看和修改 MySQL 的最大连接数

怎么查看和修改 MySQL 的最大连接数

mysql 查看数据库状态

MySQL连接数实时查看