How to Fix MySQL Error 4015 (ER_ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS_REQUIRES_GTID_MODE_ON)
You get mysql error 4015 when a replica tries to assign transaction IDs while global GTID mode is off. To fix this error, you must turn on global GTID mode on the replica first. Database teams often see this failure when moving from log file positions to transaction IDs. The replica server blocks the change to keep transaction logs safe and consistent. This guide explains why the database stops the command and how to fix it. What causes mysql error 4015 in replication MySQL uses global trans
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You get mysql error 4015 when a replica tries to assign transaction IDs while global GTID mode is off. To fix this error, you must turn on global GTID mode on the replica first.
Database teams often see this failure when moving from log file positions to transaction IDs. The replica server blocks the change to keep transaction logs safe and consistent. This guide explains why the database stops the command and how to fix it.
What causes mysql error 4015 in replication
MySQL uses global transaction identifiers, or GTIDs, to track changes across database servers. Sometimes a source server sends changes that do not have these tracking IDs. These untracked changes are called anonymous transactions.
A replica server can create new IDs for these incoming anonymous changes. It can use its own local server ID or a custom ID you pick. Still, the replica needs its own GTID engine turned all the way on first.
The database throws error code 4015 under SQL state HY000 when this rule breaks. The official symbol for this failure tells the whole story clearly. It states that assigning GTIDs to anonymous transactions requires GTID mode on.
If the replica has GTID mode off or permissive, the change command fails. The database engine refuses to make up new IDs when tracking is off. This check stops broken log chains before they start.
How to diagnose the replica state
Start your check by reading the current global variables on the replica server. Look at the variable that controls the GTID mode state on that machine. You will likely see that it is set to off or a permissive step.
Next, check the variable that enforces GTID consistency on the replica. Both settings must be active before the replica can assign IDs to incoming data. Also check if replication channels are running right now.
Single Sign-On (SSO) + MySQL Access Governance: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Do not guess which server has the wrong setting during an outage. Always run read checks on the exact replica where the command failed. Keep your admin role permissions scoped to the replica you are fixing.
How to fix mysql error 4015 safely in production
First, stop the active replication threads on the replica server. The replica must not process new events while you change its core tracking rules. Wait for all running worker threads to finish their current work.
Second, turn on GTID consistency enforcement in the global server settings. Watch the database error log to make sure no active queries break this rule. Once that check passes, step the global GTID mode up until it is on.
MySQL requires you to step through permissive modes one by one when changing live servers. Move from off to off-permissive, then to on-permissive, and finally to on. Save these changes in your server file so they stay active after a restart.
Third, run your replication source change command again on the replica. Because GTID mode is now on, the server accepts the anonymous transaction assignment rule. Start the replication threads again and check the replica status for any lag.
Keep in mind that this setup is meant as a bridge for upgrades. A replica that makes its own IDs should not replace the main source server. Plan to turn on full GTID tracking on the source server soon.
Inspect every MySQL query and response in flight
Static grants and network rules block bad logins. They cannot pause a risky query for review or mask emails in a result set. By design, hoop.dev sits inline in the MySQL protocol as a sidecar for your MySQL. For every plain query, prepared statement, or cursor an agent or human runs in production, hoop.dev decides to pass, mask, block, or hold it for review.
First, hoop.dev guardrails block banned actions before MySQL runs them, and an AI Analyzer you configure can score intent or escalate for approval. Next, hoop.dev data masking rewrites sensitive string columns in results in memory, and every verdict goes to the audit trail. Find the open-source binary on GitHub.
Frequently asked questions
What does SQL state HY000 mean for error 4015?
HY000 is a general error state used by MySQL for engine rules. You must read the specific error code 4015 to see the exact GTID rule failure.
Do I need to restart MySQL to turn on GTID mode?
No, modern MySQL versions let you change GTID mode while the server runs. You just need to step through the permissive modes in the right order.
Can I use this feature for permanent multi-source failover?
No, assigning local IDs to anonymous changes is only for data collection or migrations. The new IDs only make sense on that single replica server.
Related guides
In this post