MySQL – Show Running Queries

MySQL Show Running Queries

it is deadly simple :D.

login to your MySQL , and use this query

#
show processlist;
+--------+---------+-----------------+---------+---------+------+----------+---------------------------------------------------------------------------------------------+
| Id     | User    | Host            | db      | Command | Time | State    | Info                                                                                        |
+--------+---------+-----------------+---------+---------+------+----------+---------------------------------------------------------------------------------------------+
| 672344 | squid   | localhost       | squid   | Sleep   |   71 |          | NULL                                                                                        |
| 939004 | sqlbox  | localhost       | kannel  | Sleep   |    0 |          | NULL                                                                                        |
| 939005 | sqlbox  | localhost       | kannel  | Sleep   |    2 |          | NULL                                                                                        |
| 939006 | sqlbox  | localhost       | kannel  | Sleep   |    0 |          | NULL                                                                                        |
| 939007 | sqlbox  | localhost       | kannel  | Sleep   |    0 |          | NULL                                                                                        |
| 939008 | sqlbox  | localhost       | kannel  | Sleep   |    0 |          | NULL                                                                                        |
| 939009 | sqlbox  | localhost       | kannel  | Sleep   |    1 |          | NULL                                                                                        |
| 939010 | sqlbox  | localhost       | kannel  | Sleep   |    0 |          | NULL                                                                                        |
| 939011 | sqlbox  | localhost       | kannel  | Sleep   |    2 |          | NULL                                                                                        |
| 939012 | sqlbox  | localhost       | kannel  | Sleep   |    0 |          | NULL                                                                                        |
| 939013 | sqlbox  | localhost       | kannel  | Execute |    0 | updating | DELETE FROM `mdlr` WHERE `smsc`=? AND `ts`=?  LIMIT 1                                       |
| 939017 | sqlbox  | localhost       | kannel  | Sleep   |    0 |          | NULL                                                                                        |
| 939018 | sqlbox  | localhost       | kannel  | Query   |    0 | Updating | update `dlr_injection` set `status`=1,`dlr_mask`=new.dlr_mask where `local_dlr`=new.dlr_url |
| 939020 | sqlbox  | localhost:33629 | kannel  | Sleep   |    4 |          | NULL                                                                                        |
| 939021 | sqlbox  | localhost:33630 | kannel  | Sleep   |   21 |          | NULL                                                                                        |
| 939022 | sqlbox  | localhost:33631 | kannel  | Sleep   |    3 |          | NULL                                                                                        |
| 939023 | sqlbox  | localhost:33632 | kannel  | Sleep   |    3 |          | NULL                                                                                        |
| 939024 | sqlbox  | localhost:33633 | kannel  | Sleep   |    2 |          | NULL                                                                                        |
| 939025 | sqlbox  | localhost:33634 | kannel  | Sleep   |   84 |          | NULL                                                                                        |
| 939026 | sqlbox  | localhost:33635 | kannel  | Sleep   |   79 |          | NULL                                                                                        |
| 939027 | sqlbox  | localhost:33636 | kannel  | Sleep   |   82 |          | NULL                                                                                        |
| 939028 | sqlbox  | localhost:33637 | kannel  | Sleep   |   73 |          | NULL                                                                                        |
| 939029 | sqlbox  | localhost:33638 | kannel  | Sleep   |   78 |          | NULL                                                                                        |
| 939030 | sqlbox  | localhost:33639 | kannel  | Sleep   |   64 |          | NULL                                                                                        |
| 939031 | sqlbox  | localhost:33640 | kannel  | Sleep   |   66 |          | NULL                                                                                        |
| 939032 | sqlbox  | localhost:33641 | kannel  | Sleep   |   60 |          | NULL                                                                                        |
| 939033 | sqlbox  | localhost:33642 | kannel  | Sleep   |   66 |          | NULL                                                                                        |
| 939034 | sqlbox  | localhost:33643 | kannel  | Sleep   |   60 |          | NULL                                                                                        |
| 939035 | sqlbox  | localhost:33644 | kannel  | Sleep   |   57 |          | NULL                                                                                        |
| 939036 | sqlbox  | localhost:33645 | kannel  | Sleep   |   56 |          | NULL                                                                                        |
| 939037 | sqlbox  | localhost:33646 | kannel  | Sleep   |   37 |          | NULL                                                                                        |
| 939038 | sqlbox  | localhost:33647 | kannel  | Sleep   |   36 |          | NULL                                                                                        |
| 939039 | sqlbox  | localhost:33648 | kannel  | Sleep   |    3 |          | NULL                                                                                        |
| 972240 | billlll | localhost       | billlll | Sleep   |   65 |          | NULL                                                                                        |
| 972248 | billlll | localhost       | billlll | Sleep   |   54 |          | NULL                                                                                        |
| 972265 | root    | localhost       | NULL    | Query   |    0 | NULL     | show processlist                                                                            |
| 972267 | sqlbox  | localhost       | kannel  | Sleep   |    0 |          | NULL                                                                                        |
+--------+---------+-----------------+---------+---------+------+----------+---------------------------------------------------------------------------------------------+
#

“show processlist” it will only show the first 100 characters of the query.
if you need to see the complete query To show the full query run

#
show full processlist;
#

to get data in rows instead of columns,

#
show processlist \G;

*************************** 34. row ***************************
     Id: 972265
   User: sqlbox
   Host: localhost
     db: NULL
Command: Query
   Time: 0
  State: NULL
   Info: show processlist
*************************** 35. row ***************************
     Id: 972336
   User: billing
   Host: localhost
     db: billing
Command: Sleep
   Time: 49
  State:
   Info: NULL
35 rows in set (0.00 sec)

#

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.