Purge BINARY logs on windows
If your like me and find that your windows MySQL server is filling up disk space with it's binary logs in a Master-Master replication setup, you will have to setup a script/routine to run the following each night.
First, set expire_logs_days to be 10 in my.cnf/ini (10 or 4 or whatever days you wish to keep you binary logs for)
[mysqld]
expire_logs_days=10
Next, log in to mysql and run this
Note the query's date and time
Thus, the PURGE BINARY LOGS command will delete all binlogs whose datetime stamp predates 2012-12-11 00:00:00.
Finally, run this command
That's it. No restart needed for installing expire_logs_days.
First, set expire_logs_days to be 10 in my.cnf/ini (10 or 4 or whatever days you wish to keep you binary logs for)
[mysqld]
expire_logs_days=10
Next, log in to mysql and run this
PURGE BINARY LOGS BEFORE (date(now()) + interval 0 second - interval 10 day); |
Note the query's date and time
mysql> select date(now()) + interval 0 second - interval 10 day; +---------------------------------------------------+ | date(now()) + interval 0 second - interval 10 day | +---------------------------------------------------+ | 2012-12-11 00:00:00 | +---------------------------------------------------+ 1 row in set (0.00 sec) mysql> |
Thus, the PURGE BINARY LOGS command will delete all binlogs whose datetime stamp predates 2012-12-11 00:00:00.
Finally, run this command
SET GLOBAL expire_logs_days = 10; |
That's it. No restart needed for installing expire_logs_days.
Please Register.
If you wish to add comments.
Cheers
Adam