Common SQL Errors

MySQL Error 1387: ER_LOGGING_PROHIBIT_CHANGING_OF - Causes, Fixes, and Prevention

Galaxy Team
August 7, 2025

<p>MySQL throws error 1387 when you attempt to change a global server variable that binary logging or replication forbids from being modified online.</p>

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 1387 (ER_LOGGING_PROHIBIT_CHANGING_OF)?

<p>MySQL Error 1387: ER_LOGGING_PROHIBIT_CHANGING_OF occurs when you try to change certain global variables while binary logging or replication is active. Stop replication or disable binary logging for the session, change the variable, then re-enable logging to resolve the issue.</p>

Error Highlights

Typical Error Message

Binary logging and replication forbid changing the global

Error Type

Replication and Logging Error

Language

MySQL

Symbol

ER_LOGGING_PROHIBIT_CHANGING_OF

Error Code

1387

SQL State

HY000

Explanation

Table of Contents

What does MySQL error 1387 (ER_LOGGING_PROHIBIT_CHANGING_OF) mean?

The server raises this error when a client issues SET GLOBAL or similar statements that attempt to modify variables protected by binary logging or replication. MySQL blocks the change to keep replicas consistent and to avoid data loss.

The error message includes the name of the variable you tried to alter. Typical offenders are general_log, slow_query_log, read_only, and log_bin. The safeguard is hard-coded, so the command fails until the protection is lifted.

When does error 1387 appear?

You see the error in primary-replica setups, GTID environments, or any server started with --log-bin. It often surfaces during maintenance windows when DBAs toggle logging flags or automate variable changes through scripts.

Developers sometimes meet it inside stored procedures that execute SET GLOBAL statements, because the server executes those statements in the replication stream and blocks them.

Why is it critical to fix error 1387 quickly?

If your automation expects the variable change to succeed, the failure can halt deployments, leave verbose logging enabled, or disable important audit logs. Addressing the error keeps replication healthy and avoids performance hits from unintended logging states.

What causes MySQL error 1387?

The root cause is a conflict between the requested variable change and binary logging rules. MySQL cannot safely replicate certain dynamic changes, so it refuses the operation to guarantee deterministic replay on replicas.

Another cause is issuing the change on the wrong scope. Some variables can be altered only at the session level when binary logging is enabled. Attempting a global change triggers the error.

How do I fix MySQL error 1387?

First, assess whether you can momentarily stop replication threads. If yes, execute STOP SLAVE (or STOP REPLICA), apply the variable change, and restart replication. This keeps replicas in sync.

When downtime is impossible, disable binary logging for your session using SET sql_log_bin = 0, perform the change, then re-enable logging with SET sql_log_bin = 1. Always verify binlog format afterwards.

Best practices to avoid error 1387 in production

Plan variable changes during maintenance windows. Use configuration files for static settings and restart the server instead of changing protected variables online. Automate checks that refuse to run SET GLOBAL statements on protected variables when --log-bin is active.

Leverage a developer-centric SQL editor like Galaxy, which surfaces variable scope, alerts you before unsafe changes, and lets you run session-scoped commands with a single shortcut.

Common Causes

Changing general_log globally on a binary-logged server

The general_log variable is replicated, and altering it with SET GLOBAL general_log = 1 fails when log-bin is on.

Toggling slow_query_log during live replication

MySQL blocks global changes to slow_query_log because replicas might diverge in logging states.

Attempting SET GLOBAL read_only = 0 on a replica

The read_only flag influences statement execution order; replication forbids altering it while SQL threads run.

Disabling log_bin dynamically

Turning off binary logging online endangers replication integrity, so MySQL rejects the request.

Related Errors

MySQL Error 1386: ER_LOGGING_IMPOSSIBLE

Raised when logging cannot be started or stopped due to file or permission issues.

MySQL Error 1193: ER_UNKNOWN_SYSTEM_VARIABLE

Appears when you reference a variable that does not exist or is misspelled.

MySQL Error 1227: ER_SPECIFIC_ACCESS_DENIED_ERROR

Occurs when the account lacks SUPER or SYSTEM_VARIABLES_ADMIN privileges needed to run SET GLOBAL.

FAQs

Can I disable general_log without stopping replication?

Yes. Run SET SESSION sql_log_bin = 0, change general_log at the global scope, then set sql_log_bin back to 1. Verify replicas stay consistent.

Is error 1387 version-specific?

No. It exists from MySQL 5.0 through 8.1 because the underlying replication safety check remains unchanged.

Will changing the variable in my.cnf avoid the error?

Yes. Static configuration changes applied at startup do not conflict with binary logging rules.

How does Galaxy help prevent this error?

Galaxy flags protected variables in its AI copilot, warns before executing unsafe SET GLOBAL commands, and offers one-click session-scoped execution to bypass the error.

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