MySQL Session - Kill query to unlock table

mysql

Solution

Go into PuTTY, and then log into MySQL. Run the following in MySQL:

show processlist;

That will show a list of all running processes. You will probably be able to find the query that is locking your tables as it will likely be the longest running query with a bunch of other queries waiting for the lock release. Make a note of the process id of this query.

Then run:

kill [PROCESSID];

That will kill the process. Of course you need to do this as the user that has privilege to stop the query that was started (so use the same user or `root` if you have to).

Problem

A query has locked a table in MySQL. How can the running query's session be killed to unlock the table? I do not know to view the active sessions/processes in MySQL. How can I this via SSH?

Original source