

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do I kill all the processes in MySQL “show processlist”?
We can kill the processes with the help of the ‘kill’ command. However, you need to kill those processes one by one, since MySQL does not have any massive kill command.
To check how many processes exist, use ‘show processlist’
mysql> show processlist;
The following is the output.
+----+-----------------+-----------------+------+---------+------+------------------------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+-----------------+-----------------+------+---------+------+------------------------+------------------+ | 4 | event_scheduler | localhost | NULL | Daemon | 7986 | Waiting on empty queue | NULL | | 8 | root | localhost:65180 | test | Query | 0 | starting | show processlist | +----+-----------------+-----------------+------+---------+------+------------------------+------------------+ 2 rows in set (0.00 sec)
To kill a process which have been active for more than 10 seconds, the following is the query. Here, we are killing a process with Id “4”
mysql> select concat('kill ',4,';') -> from information_schema.processlist -> where TIME > 10;
Here is the output.
+-----------------------+once; | concat('kill ',4,';') | +-----------------------+ | kill 4; | +-----------------------+ 1 row in set (0.00 sec)
As an alterbative, you can still try the following MySQL query to kill all the processes.
mysql -e "show full processlist;" -ss | awk '{print "KILL "$1";"}'| mysql
- Related Questions & Answers
- How to customize `show processlist` in MySQL?
- What does 'show processlist' command do in MySQL?
- How to find and kill running processes in linux
- How to Kill Linux Processes Using ‘xkill’ Command
- How do I show a MySQL warning that just happened?
- How do I show unique constraints of a table in MySQL?
- How do I show the schema of a table in a MySQL database?
- How do I list all the columns in a MySQL table?
- How can I display all databases in MySQL and for each database show all tables?
- How do I use the @ sign in MySQL?
- How do I hide and show a menu item in the Android ActionBar?
- How do I set the timezone of MySQL?
- How do I close all the open pyplot windows (Matplotlib)?
- How do I lag columns in MySQL?
- How do I show the same Matplotlib figure several times in a single IPython notebook?
Advertisements