mysql如何批量杀死进程

批量杀死mysql有两种方法,一种是



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)


上面那种方法也是百度可以搜到的最多的答案,博主最开始也是用的上面的方法,但是博主是从操作的生产线上数据库,操作的时候发现在将结果导出到为到文件的时候显示权限不足,如下图所示
在这里插入图片描述
这个时候我们还是一个办法就是,先用下的sql把我们要的结果查出来

select concat('KILL ',id,';') from information_schema.processlist where user='root'

然后利用navicat导出到一个txt文档中
在这里插入图片描述
然后把上述结果全选复制到navicat里面批量执行就可以啦。

发布了45 篇原创文章 · 获赞 0 · 访问量 1229

猜你喜欢

转载自blog.csdn.net/weixin_44853669/article/details/105082709