
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
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 Articles
- 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 to End Processes With kill, pkill, and killall
- How do I show unique constraints of a table in MySQL?
- How do I list all the columns in a MySQL table?
- How do I show the schema of a table in a MySQL database?
- How do I show a MySQL warning that just happened?
- How can I display all databases in MySQL and for each database show all tables?
- How do painkillers kill pain?
- How do I use the @ sign in MySQL?
- How do I lag columns in MySQL?
- How do I set the timezone of MySQL?
- How do I hide and show a menu item in the Android ActionBar?

Advertisements