原文博客地址:
https://blog.51cto.com/imysql/308917

tcpdump -i em4 -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.=" $_";
}
}' >>/tmp/test.log

[root@localhost ~]# tailf /tmp/test.log

SET NAMES 'utf8'
UPDATE dev_login SET login_time = 1516973365, use_time = 699, count = 6 WHERE dev_id = 'a_imei866935038757910' AND login_time > 1516896000 AND login_time < 1516982400
SET NAMES 'utf8'
SELECT rid, user_id, book_id, read_time FROM novel_read_log WHERE user_id = 6783 ORDER BY read_time DESC LIMIT 30
SET NAMES 'utf8'
SELECT use_time,count FROM dev_login WHERE  dev_id = 'a_aId7a110919be02259c' AND login_time > 1516896000 AND login_time < 1516982400