Skip to content

KILL

The SQL code below demonstrates how to use the “KILL” command.

SHOW PROCESSLIST;
KILL 1234;

The result of the “SHOW PROCESSLIST” command might look like this:

+-----+-----+-----------+----+---------+------+-------+------------------+
| Id | User| Host | db | Command | Time | State | Info |
+-----+-----+-----------+----+---------+------+-------+------------------+
| 1234| root| localhost | my_db | Query | 10 | updating | UPDATE table |
| 4321| root| localhost | my_db | Query | 2 | updating | SELECT * FROM table |
+-----+-----+-----------+----+---------+------+-------+------------------+

After the “KILL” command, you would get no output:

Empty set (0.00 sec)

The “SHOW PROCESSLIST” statement lists the current MySQL server threads. Each row displays information about a thread. The “KILL” statement is used to terminate a specific thread. In this scenario, the thread with id 1234 is terminated. Note that only users with SUPER privilege can use this statement to kill threads.