如何杀掉慢查询语句
作者:互联网
1. 查看MySQL运行了哪些语句
mysql> show processlist;
+------+-----------------+-----------+------+---------+--------+------------------------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+------+-----------------+-----------+------+---------+--------+------------------------+------------------+
| 1 | event_scheduler | localhost | NULL | Daemon | 327486 | Waiting on empty queue | NULL |
| 2749 | root | localhost | test | Query | 0 | starting | show processlist |
+------+-----------------+-----------+------+---------+--------+------------------------+------------------+
2 rows in set (0.00 sec)
参数详解:
- id:当前语句的id号,可以
kill
掉- User:当前连接用户
- host:显示这个连接从哪个ip的哪个端口上发出
- db:数据库名
- command:连接状态,一般是休眠(sleep),查询(query),连接(connect)
- time:连接持续时间,单位是秒
- state:显示当前sql语句的状态
- info:显示这个sql语句
2. 杀死异常语句
查看command
、time
、state
、info
列,判断是否为异常慢查询语句,如果是就kill
掉。
mysql> kill id号;
标签:语句,连接,+------+-----------------+-----------+------+---------+--------+---------- 来源: https://blog.csdn.net/weixin_51003946/article/details/117413933