How to kill a MySQL process that takes too much time

Warning

If you force quit the process while a file is being written, it may damage the data or adversely affect its integrity.

Command

Note that “process” here means that of MySQL, not the OS.

KILL <process ID>;

Example

Try the above command in the command line interface.

# mysql -u root -p

(Log in)

mysql> SHOW PROCESSLIST;
+------+------+-----------+----------------+---------+------+--------------+-------------------+
| Id   | User | Host      | db             | Command | Time | State        | Info              |
+------+------+-----------+----------------+---------+------+--------------+-------------------+
| 4767 | root | localhost | NULL           | Query   |    0 | NULL         | show processlist  |
| 4768 | root | localhost | database       | Query   |    3 | Sending data | (snip)            |
+------+------+-----------+----------------+---------+------+--------------+-------------------+
2 rows in set (0.00 sec) 

mysql> KILL 4768;
Query OK, 0 rows affected (0.01 sec)
This post is also available in other languages.