MySQL批量杀进程方法
一、通过SQL语句
mysql> desc information_schema.processlist;
+---------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+---------------------+------+-----+---------+-------+
| ID | bigint(21) unsigned | NO | | 0 | |
| USER | varchar(32) | 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)
select concat(‘KILL ‘,id,‘;‘) from information_schema.processlist where state like ‘%User lock%‘;
select concat(‘KILL ‘,id,‘;‘) from information_schema.processlist where state like ‘%User lock%‘ into outfile ‘/tmp/a.txt‘;
二、通过mysqladimin 杀
mysqladmin -uroot -p processlist| grep -i lock| awk -F "|" ‘{print "kill" $2 ";"}‘
mysqladmin -uroot -p processlist| grep -i "lock"| awk -F "|" ‘{print $2 }‘|xargs mysqladmin -uroot -p kill
原文地址:http://blog.51cto.com/395469372/2071238