MySQL databases are great database in internet. It’s commonly used in WordPress and Drupal blog. When you are monitoring the performance of a WordPress or Drupal blog, do not forget to monitor the MySQL queries using existing tools including mytop, mtop and also running a SHOW PROCESSLIST from the mysql client command line. It will show all the queries are running and how long they take. The command SHOW PROCESSLIST actually shows you which threads are running in realtime. You can also can get this information from the mysqladmin processlist command and from the INFORMATION_SCHEMA PROCESSLIST table. If you have the PROCESS privilege, you can see all threads. Otherwise, you can see only your own threads. However, if you really need to investigate or monitor overall website performance issue, please also look at other aspects of the system such memory and swapping as well as CPU utilization.
Here is an example of SHOW PROCESSLIST output:
show processlist;
mysql> show processlist;
+----+---------------+-------------------+-------------+---------+------+-------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+---------------+-------------------+-------------+---------+------+-------+------------------+
| 23 | root | localhost | NULL | Query | 0 | NULL | show processlist |
| 46 | wordpressuser | 192.168.0.5:38876 | wordpressdb | Sleep | 69 | | NULL |
| 51 | root | localhost | wordpressdb | Sleep | 34 | | NULL |
+----+---------------+-------------------+-------------+---------+------+-------+------------------+
3 rows in set (0.00 sec)
Alternately you can run as below :
mysql> SHOW PROCESSLIST\G *************************** 1. row *************************** Id: 23 User: root Host: localhost db: NULL Command: Query Time: 0 State: NULL Info: SHOW PROCESSLIST *************************** 2. row *************************** Id: 46 User: wordpressuser Host: 192.168.0.5:38876 db: wordpressdb Command: Sleep Time: 73 State: Info: NULL *************************** 3. row *************************** Id: 51 User: root Host: localhost db: wordpressdb Command: Sleep Time: 38 State: Info: NULL 3 rows in set (0.00 sec)
You have an option to run processlist in mysqladmin command. Below example show processlist every two second :
mysqladmin -u root -p -i 2 processlist
Example :
[root@mysql-server ~]# mysqladmin -u root -p -i 2 processlist Enter password: +----+------+-----------+----+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------+----+---------+------+-------+------------------+ | 6 | root | localhost | | Query | 0 | | show processlist | +----+------+-----------+----+---------+------+-------+------------------+ +----+------+-----------+----+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------+----+---------+------+-------+------------------+ | 6 | root | localhost | | Query | 0 | | show processlist | +----+------+-----------+----+---------+------+-------+------------------+ +----+------+-----------+----+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------+----+---------+------+-------+------------------+ | 6 | root | localhost | | Query | 0 | | show processlist | +----+------+-----------+----+---------+------+-------+------------------+ +----+------+-----------+----+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------+----+---------+------+-------+------------------+ | 6 | root | localhost | | Query | 0 | | show processlist | +----+------+-----------+----+---------+------+-------+------------------+