gpt4 book ai didi

mysql - 如何找到Mysql线程

转载 作者:太空宇宙 更新时间:2023-11-04 09:06:56 25 4
gpt4 key购买 nike

我正在使用 mytop 来搜索慢速查询。例如,我发现 ID 为 110 的线程很慢 enter image description here

但是现在我的系统中有这样的线程。ps -AL

enter image description here enter image description here

有什么问题吗?为什么我看不到 ID 为 110 的线程?谢谢!

最佳答案

你在mytop看到的ID是mysql连接id,它是mysql本地的。 mytop 不会向您显示任何进程 ID(该进程甚至可能在远程计算机上运行)。

如果你想找到进程,你需要使用 mysqladmin 和 netstat:

$ mysqladmin -v pr+-----+------+----------------------+-------+---------+------+------------+-----------------------+| Id  | User | Host                 | db    | Command | Time | State      | Info                  |+-----+------+----------------------+-------+---------+------+------------+-----------------------+| 4   | uqos | 192.168.170.66:33912 | us200 | Sleep   | 8    |            |                       || 5   | uqos | 192.168.170.66:33913 | us200 | Sleep   | 8    |            |                       || 6   | uqos | 192.168.170.66:33914 | us200 | Sleep   | 8    |            |                       || 251 | uqos | 192.168.170.66:59161 | us200 | Query   | 2    | User sleep | select sleep(200)     | 254 | uqos | localhost            |       | Query   | 0    |            | show full processlist |+-----+------+----------------------+-------+---------+------+------------+-----------------------

因此,来自主机 192.168.170.66 的某个人正在从端口 59161 连接到 mysql 数据库。让我们转到该机器并找到该进程:

$ netstat -apn |grep 59161(Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.)tcp        0      0 192.168.170.66:59161        192.168.170.60:3306         ESTABLISHED 13166/mysql$ ps -ef |grep 13166uqos     13166  6635  0 14:31 pts/0    00:00:00 mysql -h 192.168.170.60 us200 -p

好了,pid为13166的进程

这是不可能的 atm。但是,如果客户端使用 unix 套接字连接,则仅当它们使用 TCP 连接时。

关于mysql - 如何找到Mysql线程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9194092/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com