Documentation Home
MySQL 8.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 45.6Mb
PDF (A4) - 45.7Mb
PDF (RPM) - 41.2Mb
HTML Download (TGZ) - 10.5Mb
HTML Download (Zip) - 10.6Mb
HTML Download (RPM) - 9.1Mb
Man Pages (TGZ) - 209.9Kb
Man Pages (Zip) - 312.0Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb
Excerpts from this Manual RESET MASTER Syntax

RESET MASTER [TO binary_log_file_index_number]

RESET MASTER enables you to delete any binary log files and their related binary log index file, returning the master to its state before binary logging was started. RESET MASTER requires the RELOAD privilege.


Use this statement with caution to ensure you do not lose binary log file data.

Issuing RESET MASTER without the optional TO clause deletes all binary log files listed in the index file, resets the binary log index file to be empty, and creates a new binary log file starting at 1. Use the optional TO clause to start the binary log file index from a number other than 1 after the reset. Issuing RESET MASTER also clears the values of the gtid_purged system variable and the gtid_executed system variable; that is, issuing this statement sets each of these values to an empty string (''). This statement also clears the mysql.gtid_executed table (see mysql.gtid_executed Table).

Using RESET MASTER with the TO clause to specify a binary log file index number to start from simplifies failover by providing a single statement alternative to the FLUSH BINARY LOGS and PURGE BINARY LOGS TO statements. Check that you are using a reasonable value for the index number. If you enter an incorrect value, you can correct this by issuing another RESET MASTER statement with or without the TO clause. If you do not correct a value that is out of range, the server cannot be restarted.

The following example demonstrates TO clause usage:


| Log_name          | File_size | Encrypted |
| master-bin.001234 |       154 | No        |

The effects of RESET MASTER without the TO clause differ from those of PURGE BINARY LOGS in 2 key ways:

  1. RESET MASTER removes all binary log files that are listed in the index file, leaving only a single, empty binary log file with a numeric suffix of .000001, whereas the numbering is not reset by PURGE BINARY LOGS.

  2. RESET MASTER is not intended to be used while any replication slaves are running. The behavior of RESET MASTER when used while slaves are running is undefined (and thus unsupported), whereas PURGE BINARY LOGS may be safely used while replication slaves are running.

See also Section, “PURGE BINARY LOGS Syntax”.

RESET MASTER without the TO clause can prove useful when you first set up the master and the slave, so that you can verify the setup as follows:

  1. Start the master and slave, and start replication (see Section 17.1.2, “Setting Up Binary Log File Position Based Replication”).

  2. Execute a few test queries on the master.

  3. Check that the queries were replicated to the slave.

  4. When replication is running correctly, issue STOP SLAVE followed by RESET SLAVE on the slave, then verify that no unwanted data from the test queries exists on the slave.

  5. Issue RESET MASTER on the master to clean up the test queries.

After verifying the setup, resetting the master and slave and ensuring that no unwanted data or binary log files generated by testing remain on the master or slave, you can start the slave and begin replicating.

User Comments
User comments in this section are, as the name implies, provided by MySQL users. The MySQL documentation team is not responsible for, nor do they endorse, any of the information provided here.
  Posted by Paul Caskey on February 15, 2012
NOTE: This command LOCKS EVERYTHING and prohibits connections to the database engine while RESET MASTER is doing its thing! This can be many minutes if you have a lot of big masterXX.bin files to delete. Ctrl-C is trapped (does not work) from your mysql> prompt while this is underway. So once it starts, you are committed to wait, and who knows what harm might come from trying harder to abort it. Use PURGE on small bites at a time if you want to avoid this locking problem.