码迷,mamicode.com
首页 > 数据库 > 详细

Mysql查看连接数相关信息

时间:2017-08-10 19:49:48      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:sub   var   style   set   and   ring   field   order   process   

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查看连接数相关信息

标签:sub   var   style   set   and   ring   field   order   process   

原文地址:http://www.cnblogs.com/zhzhang/p/7340692.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!