Home >Database >Mysql Tutorial >批量kill mysql进程_MySQL

批量kill mysql进程_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-01 13:36:461267browse

bitsCN.com

批量kill mysql进程

 

如果大批量的操作能够通过一系列的select语句产生,那么理论上就能对这些结果批量处理。    

但是mysql并没用提供eval这样的对结果集进行分析操作的功能。所以只能现将select结果保存到临时文件中,然后再执行临时文件中的指令。

具体过程如下:

 

mysql> SELECT concat('KILL ',id,';') FROM information_schema.processlist WHERE user='root';

+------------------------+

| concat('KILL ',id,';') 

+------------------------+

| KILL 3101;             

| KILL 2946;             

+------------------------+

2 rows IN SET (0.00 sec)

 

mysql> SELECT concat('KILL ',id,';') FROM information_schema.processlist WHERE user='root' INTO OUTFILE '/tmp/a.txt';

Query OK, 2 rows affected (0.00 sec)

 

mysql> source /tmp/a.txt;

Query OK, 0 rows affected (0.00 sec)

bitsCN.com
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn