MySQL 批量杀进程
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL 批量杀进程相关的知识,希望对你有一定的参考价值。
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
以上是关于MySQL 批量杀进程的主要内容,如果未能解决你的问题,请参考以下文章