The MySQL database hangs, due to some queries.
How can I find the processes and kill them?
Type in MYSQL to get into the mysql command line. Type show processlist; in order to see current processes on the server.
Just go to task manager. Then in process, search mysqld. right click on mysqld then click on stop.
KILL QUERY terminates the statement the connection is currently executing, but leaves the connection itself intact.
Here is the solution:
show full processlist;
to get the process id with status and query itself which causes the database hanging;KILL <pid>;
to kill that process.Sometimes it is not enough to kill each process manually. So, for that we've to go with some trick:
Select concat('KILL ',id,';') from information_schema.processlist where user='user';
to print all processes with KILL
command;|
sign, copy and paste all again into the query console. HIT ENTER. BooM it's done.select GROUP_CONCAT(stat SEPARATOR ' ') from (select concat('KILL ',id,';') as stat from information_schema.processlist) as stats;
Then copy and paste the result back into the terminal. Something like:
KILL 2871; KILL 2879; KILL 2874; KILL 2872; KILL 2866;
You can do something like this to check if any mysql
process is running or not:
ps aux | grep mysqld
ps aux | grep mysql
Then if it is running you can killall
by using(depending on what all processes are running currently):
killall -9 mysql
killall -9 mysqld
killall -9 mysqld_safe
On RDS:
SELECT
concat('CALL mysql.rds_kill(',id,');')
FROM information_schema.processlist
ORDER BY time;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With