When a query is running in MySQL, there are several options for killing it. One is to it, which isn’t recommended. A better way is to use MySQL’s built-in ‘kill’ command. Log in to another instance of MySQL, find the process number of the query, and kill that process. It looks a bit like the following after logging in.

mysql> show processlist;
+--------+--------+-----------+-----------+---------+------+--------------+--------------------------------+
| Id     | User   | Host      | db        | Command | Time | State        | Info                           |
+--------+--------+-----------+-----------+---------+------+--------------+--------------------------------+
| 222954 | rouser | localhost | DATABASE  | Query   | 3945 | Sending data | SELECT COUNT(*) FROM BIG_TABLE |
| 223347 | rouser | localhost | NULL      | Query   |    0 | NULL         | show processlist               |
+--------+--------+-----------+-----------+---------+------+--------------+--------------------------------+
2 rows in set (0.00 sec)
 
mysql> kill 222954;
Query OK, 0 rows affected (0.00 sec)
 
mysql>
Posted in MySQL
Share this post, let the world know

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">