我想终止进程列表中的所有 MySQL 进程。有什么办法吗?
# mysqladmin -u root -p processlist
Enter password:
+------+----------------------+---------------------+----+---------+------+-------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+------+----------------------+---------------------+----+---------+------+-------+------------------+
| 1908 | unauthenticated user | 192.168.1.103:46046 | | Connect | | login | |
| 1909 | unauthenticated user | 192.168.1.103:46047 | | Connect | | login | |
| 1910 | unauthenticated user | 192.168.1.103:46048 | | Connect | | login | |
| 1914 | unauthenticated user | 192.168.1.103:46049 | | Connect | | login | |
| 1946 | unauthenticated user | 192.168.1.103:46076 | | Connect | | login | |
| 1954 | unauthenticated user | 192.168.1.103:46078 | | Connect | | login | |
| 2015 | root | localhost | | Query | 0 | | show processlist |
+------+----------------------+---------------------+----+---------+------+-------+------------------+
答案1
看起来这可能涵盖在批量终止行为不当的 MySQL 查询
答案2
停止/启动 MySQL 实例不是解决办法。在大多数情况下,这会花费相当多的时间并影响您的生产。您应该直接终止此类查询。
两篇有趣的文章:
和:
答案3
最快的方法就是重启 MySQL。否则,您需要逐个终止每个正在运行的进程(mysqladmin 中没有 killall)。
答案4
这个 shell 命令可能有助于终止所有睡眠进程:
mysqladmin proc | grep Sleep | awk '{print $2}' | xargs -L1 mysqladmin kill