查看正在执行的语句有哪些,并做好归并排序:
mysql -uroot -e 'show processlist\G'|grep 'Info'|grep -v "NULL"|awk -F ":" '{print $2}'|sort|uniq -c|sort -rn;
查询结果:
Warning: Using a password on the command line interface can be insecure.
1 show processlist
本文介绍了一种使用Shell脚本查询并分析MySQL当前正在执行的语句的方法,通过一系列的grep、awk、sort和uniq命令组合,实现了对MySQL进程列表中执行语句的归并排序及频率统计。
查看正在执行的语句有哪些,并做好归并排序:
mysql -uroot -e 'show processlist\G'|grep 'Info'|grep -v "NULL"|awk -F ":" '{print $2}'|sort|uniq -c|sort -rn;
查询结果:
Warning: Using a password on the command line interface can be insecure.
1 show processlist
1077

被折叠的 条评论
为什么被折叠?