This is an old revision of the document!
In MySQL we can monitor the MysQL sessions and processes as follows:
Monitor connected threads
mysql> show status where variable_name = 'threads_connected'; +-------------------+-------+ | Variable_name | Value | +-------------------+-------+ | Threads_connected | 1 | +-------------------+-------+ 1 row in set (0.00 sec) mysql>
Monitor sessions
mysql> show processlist; +----+-------------+-----------+-------+---------+------+--------------------------------------------------------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+-------------+-----------+-------+---------+------+--------------------------------------------------------+------------------+ | 6 | system user | | NULL | Connect | 5950 | Waiting for master to send event | NULL | | 7 | system user | | NULL | Connect | 3384 | Slave has read all relay log; waiting for more updates | NULL | | 8 | root | localhost | repDB | Query | 0 | starting | show processlist | +----+-------------+-----------+-------+---------+------+--------------------------------------------------------+------------------+ 3 rows in set (0.00 sec) mysql>
Using a query
mysql> select id, user, host, db, command, time, state, info from information_schema.processlist\G; *************************** 1. row *************************** id: 6 user: system user host: db: NULL command: Connect time: 6049 state: Waiting for master to send event info: NULL *************************** 2. row *************************** id: 8 user: root host: localhost db: repDB command: Query time: 0 state: executing info: select id, user, host, db, command, time, state, info from information_schema.processlist *************************** 3. row *************************** id: 7 user: system user host: db: NULL command: Connect time: 3483 state: Slave has read all relay log; waiting for more updates info: NULL 3 rows in set (0.00 sec) ERROR: No query specified mysql>