MySQL :: MySQL 8.0 Reference Manual :: 15.7.8.4 KILL Statement (original) (raw)

15.7.8.4 KILL Statement

KILL [CONNECTION | QUERY] processlist_id

Each connection to mysqld runs in a separate thread. You can kill a thread with the KILL_`processlistid`_ statement.

Thread processlist identifiers can be determined from theID column of theINFORMATION_SCHEMA PROCESSLIST table, theId column of SHOW PROCESSLIST output, and thePROCESSLIST_ID column of the Performance Schema threads table. The value for the current thread is returned by theCONNECTION_ID() function.

KILL permits an optionalCONNECTION or QUERY modifier:

The ability to see which threads are available to be killed depends on the PROCESS privilege:

The ability to kill threads and statements depends on theCONNECTION_ADMIN privilege and the deprecated SUPER privilege:

You can also use the mysqladmin processlist and mysqladmin kill commands to examine and kill threads.

When you use KILL, a thread-specific kill flag is set for the thread. In most cases, it might take some time for the thread to die because the kill flag is checked only at specific intervals:

Warning

Killing a REPAIR TABLE orOPTIMIZE TABLE operation on aMyISAM table results in a table that is corrupted and unusable. Any reads or writes to such a table fail until you optimize or repair it again (without interruption).