select concat('KILL ',id-6ren">
gpt4 book ai didi

mysql - 如何杀死 Mysql "show processlist"中的所有进程?

转载 作者:IT老高 更新时间:2023-10-28 12:50:31 28 4
gpt4 key购买 nike

因为我在那里看到了很多进程,并且“时间”列显示了所有进程的大值。

最佳答案

群杀操作节省时间。在 MySql 本身中执行:

运行这些命令

mysql> select concat('KILL ',id,';') from information_schema.processlist
where user='root' and time > 200 into outfile '/tmp/a.txt';

mysql> source /tmp/a.txt;

Reference

---------edit------------

如果你不想存储在文件中,存储在一个变量

只需在命令提示符下运行

> out1=$(mysql -B test -uroot -proot --disable-column-names  -e "select concat('KILL ',id,';') from information_schema.processlist where user='root' and time > 200;")

> out2= $(mysql -B test -uroot -proot --disable-column-names -e "$out1")

关于mysql - 如何杀死 Mysql "show processlist"中的所有进程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1903838/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com