Feb 18 2013

Kill running process

Posted by Gerrit Schimpf in MySQL

Howto kill a process in Mysql

If you have a “hanging” process in MySQL and want to kill it, you use show processlist to identify the process you want to kill get get the id. Then a simple kill ID will do the job.

mysql> show processlist;

+-----+------+-----------+---------+---------+-------+-------+------------------+
| Id  | User | Host      | db      | Command | Time  | State | Info             |
+-----+------+-----------+---------+---------+-------+-------+------------------+
| 882 | user | localhost | test    | Sleep   | 27111 |       | NULL             |
| 893 | user | localhost | test    | Sleep   |   453 |       | NULL             |
| 901 | user | localhost | NULL    | Query   |     0 | NULL  | show processlist |
+-----+------+-----------+---------+---------+-------+-------+------------------+
3 rows in set (0.00 sec)

mysql> kill 882

The same can be done using mysqladmin form the command line:

    [root@host]# mysqladmin processlist
    +-----+------+-----------+---------+---------+------+-------+------------------+
    | Id  | User | Host      | db      | Command | Time | State | Info             |
    +-----+------+-----------+---------+---------+------+-------+------------------+
    | 882 | prog | localhost | test    | Sleep   | 2676 |       |                  |
    | 893 | prog | localhost |         | Sleep   | 1823 |       |                  |
    | 903 | root | localhost |         | Query   | 0    |       | show processlist |
    +-----+------+-----------+---------+---------+------+-------+------------------+
    [root@host]#

    [root@host]# mysqladmin kill 882

Link to the MySQL documentation

KILL Syntax
SHOW PROCESSLIST Syntax

One Response to “Kill running process”

  1. Mrten Says:

    Haha, planet mysql has a series currently on just this:

    http://mysqlentomologist.blogspot.nl/2013/02/when-kill-flag-is-checked-for-select.html
    http://mysqlentomologist.blogspot.nl/2013/02/when-kill-flag-is-checked-for-select_17.html

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


× 4 = twenty four