ITPub博客

首页 > 数据库 > MySQL > MySQL批量杀进程

MySQL批量杀进程

原创 MySQL 作者:haoge0205 时间:2014-08-27 11:10:43 0 删除 编辑
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博客 ” ,链接:https://blog.itpub.net/28939273/viewspace-1258682/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2013-11-28

  • 博文量
    300
  • 访问量
    1893511