Monitoring MySQL queries is a favorite pastime of MySQL administrators especially for performance reasons. 레크 리에이션의 마음에 드는 mysql mysql 쿼리를 모니터링은 성능상의 이유로 관리를 위해 특별히합니다. Here is a simple bash script to monitor long running MySQL queries in realtime using the ubiquitous ’show processlist’. 여기는 간단한 배쉬 스크립트를 실행하는 모니터 긴 mysql 검색어에 유비 쿼터스를 사용하여 실시간으로 표시 '를 processlist'합니다. The best part about this script is that you can use it to log your queries over time for later evaluation. 최고의 부분에 대해이 스크립트는 그것을 기록하는 데 사용할 수있는 시간이 지남에 대한 귀하의 검색어를 나중에 평가합니다.

 #!/bin/bash while [ 1 ] do         mysql -N -u root -p password -e 'show processlist' |grep -v 'show processlist'         sleep 2 done #! / 빈 / 배쉬하는 동안 [1]하지 mysql - n - u 루트 - p 비밀 번호 - 이메일 '보기 processlist'| grep - 승 '쇼 processlist'수면이 완료 

Note: Replace password with your actual password. 참고 사항 : 귀하의 실제 비밀 번호를 비밀 번호를 교체합니다.
Note: -N removes column headers. 참고 사항 : - n 열 헤더를 제거합니다.

This script excludes the show processlist thread itself. 이 스크립트는 processlist 스레드를 표시 그 자체를 제외합니다. You may also exclude the Sleeping threads with the following modification: 스레드를 할 수도있습니다자는 다음과 같은 변경을 제외합니다 :
mysql -N -u root -p password -e ’show processlist’ | egrep -v ‘Sleep|show processlist’ mysql - n - u 루트 - p 비밀 번호 - 이메일 '보기 processlist'| egrep - 승 '수면 | processlist 쇼'

Note: This is not the only or best solution in market. 참고 : 이것은 최고의 솔루션을 시장만이 아니하거나합니다. There is mtop script with more functionality but written in perl. 더 많은 기능이 스크립트를 mtop하지만 펄과합니다. I am alergic to perl and also couldn’t get it working in my only attempt. alergic을 나는 그것에서 작업하는 펄 또한 나의 유일한 시도를 가져올 수없습니다. So here is a simple solution in bash. 그래서 여기는 간단한 솔루션을 배쉬합니다. Personally I don’t like hacking perl scripts. 해킹 펄 스크립트를 개인적으로 난 싫어합니다.

Note: You can use slow query log too but in my experience a running top like display is better at finding bottlenecks. 참고 사항 : 검색어 로그를 사용할 수있습니다 너무하지만 내 경험에 천천히 위로 같은 디스플레이는 더 좋은 모습을 실행 병목 현상을 발견합니다. Slow query log doesn’t indicate why a query took long time. 검색어 로그 느린 쿼리를 왜 데려 긴 시간 나타내지 않습니다. It could be because it was waiting on another query to complete. 기다리는 수있습니다 이었기 때문에 그것을 다른 검색어를 완료합니다.