Common SQL Errors

MySQL Error 1186: ER_FLUSH_MASTER_BINLOG_CLOSED - How to Fix and Prevent

Galaxy Team
August 6, 2025

MySQL raises error 1186 when RESET MASTER is issued after the binary log has been closed with FLUSH LOGS or FLUSH BINARY LOGS.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 1186 (ER_FLUSH_MASTER_BINLOG_CLOSED)?

MySQL Error 1186: ER_FLUSH_MASTER_BINLOG_CLOSED occurs when you run RESET MASTER after the binary log is closed. Re-enable binary logging with SET sql_log_bin = 1 or restart MySQL with --log-bin, then re-run RESET MASTER.

Error Highlights

Typical Error Message

ER_FLUSH_MASTER_BINLOG_CLOSED

Error Type

Replication / Binary Log Error

Language

MySQL

Symbol

Binlog closed, cannot RESET MASTER

Error Code

1186

SQL State

HY000

Explanation

Table of Contents

Exact Error Message

ERROR 1186 (HY000): Binlog closed, cannot RESET MASTER

What Does MySQL Error 1186 ER_FLUSH_MASTER_BINLOG_CLOSED Mean?

The server refuses to execute RESET MASTER because binary logging is currently disabled.

Resetting requires an open active binary log so that the command can safely purge existing files and create a new one.

The condition name ER_FLUSH_MASTER_BINLOG_CLOSED is triggered mainly after FLUSH LOGS, FLUSH BINARY LOGS, or manual log-bin toggling has closed the current binary log file.

What Causes This Error?

Issuing RESET MASTER when the global variable log_bin is OFF causes MySQL to throw error 1186.

The most common path is running FLUSH LOGS; SET GLOBAL sql_log_bin = 0; or starting mysqld without the --log-bin option.

Replication cleanup scripts that flush logs before resetting can also hit this race condition if binary logging is not re-enabled between the two commands.

How to Fix MySQL Error 1186

First, reopen the binary log. Set sql_log_bin = 1 for the current session, or restart MySQL with log-bin enabled in my.cnf.

After confirming SHOW VARIABLES LIKE 'log_bin' returns ON, run RESET MASTER again.

If you only need to delete old files, use PURGE BINARY LOGS TO 'binlog.000123' instead; it works even when logging is off.

Common Scenarios and Solutions

Scheduled maintenance scripts that rotate logs may disable logging for bulk data loads. Ensure the script turns logging back on before issuing RESET MASTER.

On replicas promoted to standalone servers, log-bin may be turned off.

Enable it to reset or use PURGE BINARY LOGS for cleanup.

Best Practices to Avoid This Error

Always check log_bin status before calling RESET MASTER. Automate the check with IF clause logic. Avoid disabling binary logging on production masters.

Keep log-bin set permanently in my.cnf to survive restarts. Use PURGE BINARY LOGS for routine cleanup instead of RESET MASTER.

Related Errors and Solutions

ERROR 1534 (HY000): Currently executing BINLOG statements can conflict with RESET MASTER; wait for them to finish.

ERROR 1558 (HY000): Cannot purge log when replication threads are running.

These issues are solved by stopping replication threads or waiting for ongoing BINLOG operations to complete.

.

Common Causes

Related Errors

FAQs

Does RESET MASTER delete all binary logs?

Yes. It removes every existing binlog file and starts a new sequence at mysql-bin.000001, so use it carefully on production.

Can I reset logs on a replica?

RESET MASTER is safe on replicas if replication is stopped and the instance will not serve as a source until new coordinates are shared.

Is PURGE BINARY LOGS safer than RESET MASTER?

Yes. Purging lets you keep recent logs while deleting older ones needed for point-in-time recovery.

How does Galaxy help prevent this error?

Galaxy’s SQL editor surfaces server variables inline, so you can verify log_bin status before running administrative commands and share vetted scripts with your team.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo