Last active
March 8, 2022 09:04
-
-
Save ffeast/877aff9d45fd884a8e5b to your computer and use it in GitHub Desktop.
Mysql traffic tcpdump one-liner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a handy one-liner to print out sql queries if you wouldn't like to enable | |
# queries logging in mysql server itself | |
tcpdump -i lo -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\n"; } | |
$q=$_; | |
} else { | |
$_ =~ s/^[ \t]+//; $q.=" $_"; | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
is very good im working in a version that detect if a query has success or not