How To See MySQL Traffic Using tcpdump
Quick-and-dirty way: tcpdump -i eth0 -s 0 -l -X dst port 3306 NOTE: That option above is a dash-ELL which provides for unbuffered output. Maciej Dobrzanski posted the following script on the Percona site at https://www.percona.com/blog/2008/11/07/poor-mans-query-logging/, which I am reposting without permission because it is so good:
1 2 3 4 5 6 7 8 9 |
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)/i) { if (defined $q) { print "$q\n"; } $q=$_; } else { $_ =~ s/^[ \t]+//; $q.=" $_"; } }' |