如何杀死Mysql中的所有进程“show processlist”? [英] How do I kill all the processes in Mysql "show processlist"?

查看:2114
本文介绍了如何杀死Mysql中的所有进程“show processlist”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因为我看到很多进程,并且time列显示所有进程的大值。

Because I see a lot of processes there, and the "time" column shows big values for all of them.

推荐答案

你需要逐个杀死他们,MySQL没有任何大规模杀死命令。您可以使用任何语言编写脚本,例如在PHP中,您可以使用类似:

You need to kill them one by one, MySQL does not have any massive kill command. You can script it in any language, for example in PHP you can use something like:

$result = mysql_query("SHOW FULL PROCESSLIST");
while ($row=mysql_fetch_array($result)) {
  $process_id=$row["Id"];
  if ($row["Time"] > 200 ) {
    $sql="KILL $process_id";
    mysql_query($sql);
  }
}

这篇关于如何杀死Mysql中的所有进程“show processlist”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆