Tuesday, August 13, 2013

MySQL Purge Binary Logs (aka MySQL is taking up too much hard drive space)

Credit goes to this MySQL documentation.

My MySQL installation by default keeps a set of binary log files recording data changes. With many database modifications, these grow to be very large (terabytes). It isn't mission critical that we be able to recover our database at any given moment since our raw data is archived, and the database can be repopulated if need be, so I typically clean these out once hard drive space starts becoming an issue.
$ mysql -u root
mysql> PURGE BINARY LOGS BEFORE CURDATE();
This gets rid of all binary logs made before the date you run the command. You could also set the system variable expire_logs_days.

No comments:

Post a Comment