Skip to content

Instantly share code, notes, and snippets.

@Capncavedan
Created May 31, 2012 16:46
Show Gist options
  • Save Capncavedan/2844679 to your computer and use it in GitHub Desktop.
Save Capncavedan/2844679 to your computer and use it in GitHub Desktop.
Analyze MySQL binary log file
# 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