How to Fix MySQL Error 1518 (ER_NO_BINLOG_ERROR)
You see mysql error 1518 when a command tries to turn off the binary log where it is not allowed. To fix it, enable binary logging for your session or run the command outside a restricted block. In the database engine, this failure maps to symbol ER_NO_BINLOG_ERROR and SQLSTATE HY000. The server returns the exact message: It is not allowed to shut off binlog on this command. Database teams hit this roadblock during schema changes, bulk loads, or admin maintenance. Why mysql error 1518 happens
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 see mysql error 1518 when a command tries to turn off the binary log where it is not allowed. To fix it, enable binary logging for your session or run the command outside a restricted block.
In the database engine, this failure maps to symbol ER_NO_BINLOG_ERROR and SQLSTATE HY000. The server returns the exact message: It is not allowed to shut off binlog on this command. Database teams hit this roadblock during schema changes, bulk loads, or admin maintenance.
Why mysql error 1518 happens in the database engine
The binary log records all changes to your database data and structure. Read replicas need this log to stay in sync with the primary node. Point-in-time recovery also depends on having a complete chain of binary log events.
Sometimes, an engineer or a migration script turns off binary logging for a single session. They do this to skip replicating local maintenance or to speed up large imports. Still, the database engine blocks you from disabling the binary log during specific commands.
If a command must write to the log to keep nodes consistent, the server rejects it. You will also hit this error if a stored routine tries to pause logging mid-run. The database protects itself from split-brain states by halting the query right away.
Diagnosing the failing query and session state
First, find the exact statement that triggered the HY000 state in your database logs. Look at the queries that ran in the same session right before the crash. You will often find a session statement that turned off binary logging earlier.
Connection pools can make this bug hard to track down in a busy app. One worker might turn off logging for a quick task and return the connection. The next worker grabs that same connection and runs a normal command that fails.
MySQL Access Governance + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Check your migration scripts and admin jobs for any commands that alter log settings. Inspect stored procedures and triggers as well, since they inherit the active session state. Once you find where logging gets turned off, you can plan a safe fix.
How to fix the error in production safely
The safest fix is to keep binary logging turned on for your session. Remove the statement that disables the log before running the blocked command. If you use a connection pool, reset the session state before returning connections.
Do not grant broad admin roles to app users just to bypass logging rules. Only high-level database admins should have the power to pause the binary log. Standard apps and automated scripts should never touch session log settings in production.
When admins run manual fixes, they also need to protect private data in results. Data masking rewrites matched fields like emails, phone numbers, card numbers, and national IDs. This keeps sensitive records safe while your team fixes the binary log problem.
Add wire guardrails and masking beside MySQL
Database grants and TLS setup decide who can reach MySQL. Even so, an open session can run broad updates or read raw personal data from allowed tables. In practice, hoop.dev sits inline in the wire protocol beside the database as a sidecar for your MySQL. On every production query an agent or engineer sends, hoop.dev decides to pass, mask, block, or escalate it for human review.
With hoop.dev MySQL support, guardrails refuse bad queries before they run or hold risky calls for approval, while data masking rewrites matched sensitive values in result rows in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for GDPR, HIPAA, and PCI DSS programs. Read the docs and source on GitHub.
Frequently asked questions
What does the ER_NO_BINLOG_ERROR symbol mean?
ER_NO_BINLOG_ERROR is the system symbol for error code 1518 and SQLSTATE HY000. It means the server blocked a command because binary logging was turned off.
Can a connection pool cause this error for normal queries?
Yes, if one task turns off session binary logging and does not turn it back on. The next task using that pooled connection will fail when running restricted commands.
Is it safe to turn off the binary log in production?
Turning off the binary log in production is risky and breaks replica sync. Only do this for planned maintenance when you want to skip replication on purpose.
Related guides
In this post