Jump to Navigation

067 - MySQL KILL Command

Use KILL statement to terminate a client connection to MySQL. You can use the SHOW PROCESSLIST statement
to obtain a connection thread identifier for use in this statement.
As of MySQL 5.x, you can use CONNECTION or QUERY keywords to distinguish between terminating a connection or
terminating just the current query associated with the given connection.

Some process cannot be terminated immediately. Instead, this statement flags the process for termination. The system
may not check the flag until the process is completed.
This will occur with statements such as REPAIR TABLE. Bisides, you shouldn't attempt to terminate the execution
of the REPAIR TABLE or the OPTIMIZE TABLE statements. That will corrupt a MyISAM table. The utility mysqladmin
with the options processlist and KILL may be used from the command line to execute these related statements.

Example:

SHOW PROCESSLIST \G

........

id             : 14498
User         : reader
Host         : localhost
db            : database01
Command : Query
Time        : 8
State        : Sending data
Info         : SELECT COUNT(*) AS hits FROM apache_log WHERE SUBDATE(NOW(), INT .......

KILL QUERY 14498;

MySQL:


Main menu 2

Story | by Dr. Radut