1、按客户端 IP 分组,看哪个客户端的链接数最多
SELECT
client_ip,
count( client_ip ) AS client_num
FROM
( SELECT substring_index( HOST, ':', 1 ) AS client_ip FROM information_schema.PROCESSLIST ) AS connect_info
GROUP BY
client_ip
ORDER BY
client_num DESC;
2、查看正在执行的线程,并按 Time 倒排序,看看有没有执行时间特别长的线程
SELECT
*
FROM
information_schema.PROCESSLIST
WHERE
Command != 'Sleep'
ORDER BY
Time DESC;
3、查询线程及相关信息
show full processlist