MySQL Purge Binary Logs: Difference between revisions

From UNIX Systems Administration
Jump to navigation Jump to search
No edit summary
m (Michael Kohler moved page MYSQL Purge Binary Logs to MySQL Purge Binary Logs without leaving a redirect)
 
(No difference)

Latest revision as of 16:23, 30 September 2013

  1. Change to the directory containing the binary log files.
  2. Login to the all slave servers.
    1. # mysql -p -uroot
      1. Check which log file it is reading.
        1. mysql> SHOW SLAVE STATUS;
      2. 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.
  3. On the master server, flush the logs.
    1. # mysqladmin flush-logs -p -uroot
  4. Login to the master server.
    1. # mysql -p -uroot
      1. Obtain a listing of the binary log files.
        1. mysql> SHOW BINARY LOGS;
  5. Make a backup of all the log files you are about to delete. (This step is optional, but always advisable.)
  6. Purge the binary logs.
    1. mysql> PURGE BINARY LOGS BEFORE 'yyyy-mm-dd hh:mm:ss'; (note: the seconds is optional)

Further Reading

  1. MySQL Reference Guide - PURGE BINARY LOGS Syntax