How to Fix MySQL Error 1428 (ER_WRONG_LOCK_OF_SYSTEM_TABLE)

Published
Length
3 min read

Luis Felipe Dias

All posts

You trigger mysql error 1428 when a query locks system tables and user tables together. To fix it, split your table locks into separate steps or remove direct system locks. MySQL protects its core metadata with strict locking rules. When an app or backup script breaks these rules, the server stops the request right away. The database returns the symbol ER_WRONG_LOCK_OF_SYSTEM_TABLE and the state HY000. Understanding why the engine blocks mixed locks helps your team fix scripts fast. What caus

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 trigger mysql error 1428 when a query locks system tables and user tables together. To fix it, split your table locks into separate steps or remove direct system locks.

MySQL protects its core metadata with strict locking rules. When an app or backup script breaks these rules, the server stops the request right away. The database returns the symbol ER_WRONG_LOCK_OF_SYSTEM_TABLE and the state HY000. Understanding why the engine blocks mixed locks helps your team fix scripts fast.

What causes mysql error 1428 in your database

The server message states that you cannot mix write locks on system tables with other tables. You also cannot mix write locks on system tables with other lock types. MySQL stores user roles, permissions, and time zone details inside its internal system database. The engine treats these internal tables very differently from your normal app tables.

In normal operations, MySQL manages locks on internal tables by itself during account changes. Sometimes, a database admin or an older backup tool tries to lock tables by hand. If that request asks for a write lock on a system table and a user table, it fails. Even combining a system write lock with a read lock on another table triggers this error.

Dump utilities and migration scripts are the most common culprits behind this failure. When a script prepares to copy all databases at once, it may request a single big lock. Because the internal system schema sits next to your app schemas, the script groups them together. The database engine sees the mixed lock request and rejects the whole batch.

How to find and fix the locking failure

Start by checking your app logs and database error logs for the exact failing task. Look for backup jobs, upgrade scripts, or manual admin sessions running at that timestamp. Once you find the script or client session, inspect how it groups schemas during lock requests.

The safest fix is to stop locking internal system tables by hand in your scripts. If you are running a backup tool, set it up to use a single transaction snapshot instead. Transaction snapshots capture consistent data across your tables without requesting explicit write locks on system schemas. If you must back up system tables, export the internal schema in a separate step.

DPoP (Demonstration of Proof-of-Possession) + MySQL Access Governance: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

If a custom script needs to edit system tables directly, rewrite the job to use built-in account statements. Standard account management commands let the engine handle internal locks safely without manual intervention. Never grant broad system table write roles to standard app users just to work around lock errors. Splitting user data jobs from system admin tasks keeps your database safe and stable.

How to prevent system table lock conflicts

Review your scheduled maintenance jobs and deployment pipelines for outdated lock commands. Many legacy scripts still use manual table locks left over from older storage engine setups. Modern transactional engines do not need manual write locks across multiple schemas to keep data safe.

You should also restrict which database roles can touch the internal system schema. Give your app accounts permissions only for the specific user schemas they need to read or write. When routine scripts cannot touch system tables, they cannot trigger mixed lock failures in production. Clear role boundaries protect both your uptime and your data security.

Check MySQL queries and results on the wire

MySQL grants control who logs in. They do not check single queries or mask sensitive columns once a session starts. With hoop.dev, you run an open-source proxy, a sidecar for your MySQL, inline in the MySQL wire protocol. On every query an AI agent or human runs against production MySQL, RDS, or Aurora, hoop.dev decides to pass, mask, block, or hold it for review.

Multi-statement batches and prepared queries are split and checked one by one by hoop.dev guardrails, which refuse banned queries with a native MySQL error or hold risky ones for approval. On the response path, hoop.dev data masking rewrites string values in returned rows in memory, and every decision is logged. See the MIT-licensed project on GitHub.

Frequently asked questions

What does ER_WRONG_LOCK_OF_SYSTEM_TABLE mean in MySQL?

This symbol means a session tried to combine a system table write lock with other table locks. MySQL blocks this action and returns error code 1428 with SQLSTATE HY000.

Why does my database backup trigger mysql error 1428?

Backup tools trigger this error when they try to write-lock system schemas and app schemas together. Switching the backup job to use transactional snapshots or separate schema runs fixes the problem.

Should I edit MySQL system tables directly with write locks?

No, you should avoid locking and editing internal system tables by hand in production. Always use standard account and permission statements so the database engine manages its own locks safely.

The query runs. The emails stay hidden.