Sunday, April 06, 2008

MySQL: Purge Master Logs

Binary logs sometime take up too much space on the server. I wanted space so I had to delete the database logs. They were taking up around 2GB space.

http://dev.mysql.com/doc/refman/5.0/en/purge-master-logs.html --> this link will tell you how to delete the logs.

If you want to turn off the logs, then edit /var/mysql/my.cnf on Ubuntu and comment out the following lines
  • line starting with log_bin
  • line starting with expire_log_days
  • line starting with max_binlog_size
If you want to save space and also want the logs then you can ignore commenting log_bin line and try reducing the values for expire_log_days and max_binlog_size.

expire_log_days will tell you the number of days for which the logs will be kept. If it's value is 2. Then all logs older than 2 days will be deleted.

max_binlog_size is the maximum size of the log file. If a log file reaches this limit, then a new log file will be created and appended to. Note, the old log file will not be deleted unless expire_log_days condition satisfies.

No comments: