Article Title: Batch killmysql processes. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
If a large number of operations can be produced through a series of select statements, the results can be processed in batches theoretically.
However, mysql does not provide the eval function for analyzing the result set. Therefore, you can only save the select result to a temporary file and then execute the commands in the temporary file.
The specific process is as follows:
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)