1、mysql连续显示状态命令:
[root@localhost ~]# mysqladmin -uroot -ppassword extended -r -i 10
mysql> show processlist;
+-------+-----------+-----------------+---------+---------+------+----------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+-------+-----------+-----------------+---------+---------+------+----------------+------------------------------------------------------------------------------------------------------+
| 52963 | root | localhost | NULL | Query | 0 | NULL | show processlist |
| 55776 | sxcaqh1_f | localhost:
40643 | sxcaqh1 | Sleep | 0 | | NULL |
| 55779 | sxcaqh1_f | localhost:
40644 | sxcaqh1 | Query | 0 | Sorting result | SELECT id,title,submit_date,bedeck from biweb_cn_cayj where id < 2882 ORDER BY id DESC,submit_date |
+-------+-----------+-----------------+---------+---------+------+----------------+------------------------------------------------------------------------------------------------------+
3 rows in set (0.00 sec)
2、应用进程和端口号对应查看:
[root@localhost ~]# cat /etc/services | grep
40634
[root@localhost ~]# grep 3306 /etc/services
mysql 3306/tcp # MySQL
mysql 3306/udp # MySQL
通过以上方法查找那个进程咱占用mysql资源,首先确定mysql连接中的端口号,再通过该进程找到对应的端口号找到对应的进程,最后通过进程号看看是那个进程占用并影响了mysql进程。
转载于:https://blog.51cto.com/shouhouzhe/1376889