Solving MySQL Error 1186: Dealing with ‘Binlog closed, cannot RESET MASTER’

Understanding Error 1186

MySQL Error 1186 with SQLSTATE HY000 occurs when you try to execute the RESET MASTER command while the binary logging is disabled. The binary log is a set of log files that contains information about data modifications made by the MySQL server instance. The RESET MASTER command is used to clear the contents of the binary log files.

Common Reasons for Error 1186

  1. Binary Logging Not Enabled: Attempting to reset the master when binary logging is turned off.
  2. Incorrect Server Configuration: The configuration file might be set to disable binary logging.
  3. Server Runtime Changes: Binary logging could have been turned off during server runtime.

Diagnosing the Problem

To diagnose Error 1186, you should:

  1. Check if binary logging is enabled by running the following command:
  1. If the value is OFF, binary logging is not enabled.

Fixing the Error

Here are some steps to resolve Error 1186:

1. Enabling Binary Logging

To enable binary logging, you need to edit the MySQL configuration file (my.cnf or my.ini), typically located in /etc/mysql/ on Unix/Linux systems or in the MySQL installation directory on Windows.

Add the following lines under the [mysqld] section:

log_bin = /var/log/mysql/mysql-bin.log

The path /var/log/mysql/mysql-bin.log should be replaced with the appropriate path where you want to store your binary logs.

After making changes, restart the MySQL server:

sudo service mysql restart

2. Verifying Binary Logging Status

After restarting the server, verify that binary logging is enabled:


The value should now be ON.

3. Resetting the Master

Once binary logging is enabled, you can safely run the RESET MASTER command:


This command will remove all binary log files listed in the index file, reset the binary log index file to be empty, and create a new binary log file.

4. Checking File Permissions

Ensure that the MySQL server has the necessary permissions to write to the binary log file location:

sudo chown mysql:mysql /var/log/mysql/
sudo chmod 750 /var/log/mysql/

Replace /var/log/mysql/ with the directory you have specified for your binary logs.

By confirming binary logging is enabled and properly configured, you can effectively resolve Error 1186. If you’re still encountering issues after following these steps, it’s advisable to review the MySQL documentation regarding binary logging or seek further assistance from the MySQL community.

Leave a Comment