Kill a blocking (long running) sql statement

You can use the command line tool mysqladmin to view processes which returns the processes with their IDs. Then use the kill option of mysqladmin to kill your blocking process by its process ID.

 
/* get process ID of blocking process */
mysql/bin>mysqladmin -uroot -p processlist

/* kill it */
mysql/bin>mysqladmin -uroot -p kill PreceessID 

If you are using mysql client tool and already logged in as root user.

 
mysql> show processlist;

/* get process ID from output and replace with PreceessID */
mysql> kill PreceessID;

Note: Do not kill commands like Alter table, optimize table, check table...

Comments

Popular posts from this blog

Detecting user's screen size and resolution

autoload class

MySql Slow Queries