原文参考:http://www.davidodwyer.com/category/tags/tcpdump-mysql
#!/bin/bash
tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings | perl -e '
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.=" $_";
}
}'
可以根据自己的需要稍微改改,我在这里只增加了对 CALL 关键字。
最近评论
1 天 13 小时 前
1 天 15 小时 前
1 周 1 天 前
1 周 1 天 前
2 周 1 天 前
2 周 3 天 前
3 周 4 天 前