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>