Go back to the main page

Quickly remove bin logs in MySQL

 
cd /usr/local/mysql/data
# First do a test run thru to make sure you are removing
# what you intend. The -ctime +30 matches files created 30
# days ago and later. The -name "*-bin*" of course matches
# the MySQL bin files.
find -ctime +30 -name "*-bin*" -exec ls -alh {} \;
# Then remove'em
find -ctime +30 -name "*-bin*" -exec rm {} \;
# Lastly, make sure you have MySQL automatically
# remove the log files by putting this setting in my.cnf
expire_logs_days = 15 # Only keep logs around for 15 days
# Restart MySQL

  • Pushed on 01/03/2011 by Christian