MySQL show processlist过滤
show full processlist;
#根据USER过滤
select *
from information_schema.processlist
where USER="UserName"
order by HOST;
#根据HOST IP过滤,由于HOST包括Port,需要提取IP
select *
from information_schema.processlist
where LEFT(HOST, instr(HOST, ':')-1)='192.168.10.1'
order by HOST;
#根据IP统计连接数
select LEFT(HOST, instr(HOST, ':')-1) as IP, count(*) as count from information_schema.processlist group by IP order by IP;
select substr(HOST, 1, instr(HOST, ':')-1) as IP, count(*) as count from information_schema.processlist group by IP order by IP;
参考: MySQL show processlist过滤 https://blog.csdn.net/weixin_34293246/article/details/89731630 SHOW PROCESSLIST Syntax https://dev.mysql.com/doc/refman/5.7/en/show-processlist.html MySQL常用字符串函数 https://www.cnblogs.com/geaozhang/p/6739303.html