If you are a Database Administrator then you should know about  Purge MySQL Binary Logs periodically. If you are having a replication environment then you can find so many binary files in your master server. This will eat-up lot of space of your hard disk.

what is MySQL Binary Logs.– The binary log is a set of log files that contain information about data modifications made to a MySQL server instance. The log is enabled by starting the server with the –log-bin option

Let see how can we manage this Log files.

if you need to delete all binary logs older than 10 days, you just need to run this sql:
mysql> PURGE BINARY LOGS BEFORE DATE_SUB( NOW( ), INTERVAL 10 DAY);
To purge all logs before a specific date:
mysql> PURGE MASTER LOGS BEFORE '2010-04-01 00:00:00';
To purge logs automatically (every Monday at 4am) you could use a cron job like this:
0 4 * * mon mysql -uroot -e 'PURGE BINARY LOGS BEFORE DATE_SUB( NOW( ),

Thats all

Post By Editor (2,827 Posts)

Website: →

Connect