最近程序运行巨卡,通常排查方式:查看服务器网络、内存使用情况、cpu使用情况、mysql线程占用情况,查找程序本身原因。
而查看mysql的情况则用到:SHOW PROCESSLIST
SHOW PROCESSLIST:显示哪些线程正在运行
如果您有root权限,您可以看到所有线程。否则,您只能看到登录的用户自己的线程,通常只会显示100条如果想看跟多的可以使用full修饰(show full processlist)
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;
select * from information_schema.processlist where Command != ‘Sleep‘ order by Time desc;
select concat(‘kill ‘, id, ‘;‘) from information_schema.processlist where Command != ‘Sleep‘ and Time > 60 order by Time desc;
原文:https://www.cnblogs.com/1439107348s/p/14267112.html