How to list down all the running queries in MySQL?

MySQLMySQLi Database

To list running queries, we need to use the ‘show processlist’ command.

The following is the query.

mysql> SHOW processlist;

The following is the output of the above query.

+----+-----------------+-----------------+----------+---------+-------+------------------------+------------------+
| Id | User            | Host            | db       | Command | Time  | State                  | Info             |
+----+-----------------+-----------------+----------+---------+-------+------------------------+------------------+
|  4 | event_scheduler | localhost       | NULL     | Daemon  | 13785 | Waiting on empty queue | NULL             |
|  9 | root            | localhost:63587 | business | Query   |     0 | starting               | show processlist |
+----+-----------------+-----------------+----------+---------+-------+------------------------+------------------+
2 rows in set (0.00 sec)

Let us display the result horizontally with the help of SHOW command.

mysql> SHOW FULL PROCESSLIST\G;

The following is the output of the above query.

*************************** 1. row ***************************
     Id: 4
   User: event_scheduler
   Host: localhost
     db: NULL
Command: Daemon
   Time: 17385
  State: Waiting on empty queue
   Info: NULL
*************************** 2. row ***************************
     Id: 9
   User: root
   Host: localhost:63587
     db: business
Command: Query
   Time: 0
  State: starting
   Info: SHOW FULL PROCESSLIST
2 rows in set (0.00 sec)
raja
Published on 20-Nov-2018 16:47:48
Advertisements