MySQL批量殺程式

haoge0205發表於2014-08-27
OS: CentOS 6.3

DB:5.5.14

mysql> show processlist;
+----+------+-----------+--------------------+---------+------+-------+------------------+
| Id | User | Host      | db                 | Command | Time | State | Info             |
+----+------+-----------+--------------------+---------+------+-------+------------------+
| 37 | root | localhost | information_schema | Query   |    0 | NULL  | show processlist |
| 38 | root | localhost | NULL               | Sleep   |  559 |       | NULL             |
+----+------+-----------+--------------------+---------+------+-------+------------------+



mysql> kill 40;
1 row in set (0.00 sec)


mysql> use information_schema


mysql> select id from processlist;
+----+
| id |
+----+
| 40 |
+----+
1 row in set (0.00 sec)



mysql> select concat('kill ',id,';') from information_schema.processlist where user='root' into outfile '/export/yoon.txt';
Query OK, 1 row affected (0.09 sec)


[root@db01 export]# more yoon.txt 
kill 40;


批量刪除會話:
mysql> source /export/yoon.txt

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28939273/viewspace-1258682/,如需轉載,請註明出處,否則將追究法律責任。

相關文章