Created
May 31, 2012 16:46
-
-
Save Capncavedan/2844679 to your computer and use it in GitHub Desktop.
Analyze MySQL binary log file
This file contains 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
# from http://dzone.com/snippets/analyse-binary-log | |
# cat /bin/mylog | |
#!/bin/sh | |
# usage: | |
#$ mylog /mysql-bin-log/db-bin.000223 | |
# 2132 insert into customers | |
# 1887 update userlog_access | |
# 788 insert into gn_commission | |
# 718 insert into con_tab | |
mysqlbinlog ${1} | grep -i -e "^update" -e "^insert" -e "^delete" -e "^replace" -e "^alter" | cut -c1-100 | tr '[A-Z]' '[a-z]' | sed -e "s/\t/ /g;s/\`//g;s/(.*$//;s/ set .*$//;s/ as .*$//" | sed -e "s/ where .*$//" | sort | uniq -c | sort -nr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment