KILL CONNECTION
描述
杀死一个指定连接 ID 的连接。进而会杀死此连接对应的查询。
语法
KILL [ CONNECTION ] <connection_id>
必选参数
<connection_id>
链接的 ID。可以通过 SHOW PROCESSLIST 语句查询。
权限控制
执行此 SQL 命令的用户必须是此连接所属的用户,或者至少具有ADMIN_PRIV
权限
示例
查询 connection_id
:
show processlist;
结果如下:
+------------------+----+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+------------------+--------------+--------------+
| CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | FE | CloudCluster |
+------------------+----+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+------------------+--------------+--------------+
| Yes | 16 | root | 127.0.0.1:63746 | 2024-11-04 20:18:07 | internal | test | Query | 0 | OK | e4d69a1cce81468d-91c9ae32b17540e9 | show processlist | 172.16.123.1 | NULL |
+------------------+----+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+------------------+--------------+--------------+
发送 KILL 命令
KILL CONNECTION 16;