Syntax
KILL [HARD | SOFT] [CONNECTION | QUERY] [thread_id | USER user_name]
The options HARD | SOFT and USER username are
new in MariaDB 5.3.2
Description
Each connection to mysqld runs in a separate thread. You can see which threads
are running with the SHOW PROCESSLIST statement and kill a
thread with the KILL thread_id statement.
KILL allows the optional CONNECTION or
QUERY modifier:
KILL CONNECTIONis the same asKILLwith no modifier: It terminates the connection associated with the given thread_id.KILL QUERYterminates the statement that the connection is currently executing, but leaves the connection itself intact.
If you have the PROCESS privilege, you can see all threads. If
you have the SUPER privilege, you can kill all threads and
statements. Otherwise, you can see and kill only your own threads and
statements.
The HARD option (default) kills a command ASAP. If you use
SOFT, then critical operations that may leave a table in an
inconsistent state will not be interrupted. Such operations are:
REPAIRandINDEXcreation for MyISAM and Aria tables.
KILL ... USER username will kill all connections/queries for a
given user. USER can be specified one of the following ways:
- username (Kill without regard to hostname)
- username@hostname
CURRENT_USERorCURRENT_USER()
Note: You cannot use KILL with the Embedded MySQL Server
library because the embedded server merely runs inside the threads of the host
application. It does not create any connection threads of its own.
Note: You can also use
mysqladmin kill thread_id [,thread_id...]
to kill connections. To get a list of running queries,
use mysqladmin processlist.