用Tcpdump抓取MySQL执行的SQL

来源:互联网 发布:css3动画和js动画 编辑:程序博客网 时间:2024/04/30 19:40

!/bin/bash
tcpdump -i eth0 -s 0 -l -w out.log port 3306 | strings | perl -e '
#!/bin/bash
while(<>) { chomp; next if /^[^ ]+[ ]*$/;
if(/^(SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER|CALL)/i) {
if (defined $q) { print "$q/n" ; }
$q=$_;
} else {
$_ =~ s/^[ /t]+//; $q.=" $_" ;
}
}'

运行并抓去sql的执行。

抓取后在当前目录出现out.log文件,执行strings out.log即可看到sql的运行情况

原创粉丝点击