歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> Linux下查找連接了mysql的進程

Linux下查找連接了mysql的進程

日期:2017/3/3 17:00:44   编辑:關於Linux

 當遇到mysql很卡,然後又想知道找到原因時,我常用以下方法找問題

  show processlist\G; 或者show full processlist\G;

  *************************** 5. row ***************************

  Id: 197343

  User: root

  Host: 127.0.0.1:41354

  db: xxx

  Command: Query

  Time: 0

  State: Sleep

  Info: show process list

  獲取到端口後,可以查下端口訪問狀態

  # netstat -anp|grep 41354

  tcp 0 0 127.0.0.1:41354 127.0.0.1:3307 ESTABLISHED 1167/php test.php

  這樣就知道了是php test.php在連接數據庫,pid是1167

  可以lsof -p pid找到位置

  通過此方法去分析有哪些類似的程序在連數據庫,導致數據庫卡

Copyright © Linux教程網 All Rights Reserved