MySQL Purge Binary Logs
Jump to navigation
Jump to search
- Change to the directory containing the binary log files.
- Login to the all slave servers.
- # mysql -p -uroot
- Check which log file it is reading.
- mysql> SHOW SLAVE STATUS;
- Determine the earliest log file among all the slaves. This is the target file. If all the slaves are up to date, this is the last log file on the list.
- Check which log file it is reading.
- # mysql -p -uroot
- On the master server, flush the logs.
- # mysqladmin flush-logs -p -uroot
- Login to the master server.
- # mysql -p -uroot
- Obtain a listing of the binary log files.
- mysql> SHOW BINARY LOGS;
- Obtain a listing of the binary log files.
- # mysql -p -uroot
- Make a backup of all the log files you are about to delete. (This step is optional, but always advisable.)
- Purge the binary logs.
- mysql> PURGE BINARY LOGS BEFORE 'yyyy-mm-dd hh:mm:ss'; (note: the seconds is optional)