Name

KILL

Synopsis

KILL [CONNECTION|QUERY] thread

Use this statement to terminate a client connection to MySQL. You can use the SHOW PROCESSLIST statement to obtain a connection thread identifier. As of Version 5, you can use CONNECTION or QUERY flags to distinguish between terminating a connection or terminating just the query associated with the connection for the given thread. Some processes 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.

Here is an example of this statement:

KILL 22;

This simple example terminates the connection for the client associated with the thread identifier 22. If that client attempts to issue another SQL statement, it will receive an error 2006 message stating that the MySQL server has gone away. Then it typically will try to reconnect to the server, establish a new thread, and run the requested query.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.