Friday, April 2, 2010

[Level 3] Show MySQL Porcess in CentOS

Three processes to get process info:

1. show all process:
mysq> show processlist;
+----+------+-----------------+------+---------+------+-------+------------------+
| Id | User | Host            | db   | Command | Time | State | Info             |
+----+------+-----------------+------+---------+------+-------+------------------+
|  1 | root | localhost:47605 | NULL | Sleep   |   27 |       | NULL             |
| 16 | root | localhost       | test | Query   |    0 | NULL  | show processlist |
+----+------+-----------------+------+---------+------+-------+------------------+
2 rows in set (0.00 sec)

2. get process that use port 47605:

mysql> \! netstat -ntp | grep 47605
tcp        0      0 127.0.0.1:47605             127.0.0.1:3306              ESTABLISHED 2629/mysql-monitor-
tcp        0      0 127.0.0.1:3306              127.0.0.1:47605             ESTABLISHED 17920/mysqld

3. get process that pid equal 2629:
mysql> \! netstat -ntp | grep 2629



Wish this helps.

regards,
Stanley Huang