How to Fix MySQL Error 1874 (ER_INNODB_READ_ONLY)

Published
Length
3 min read

Luis Felipe Dias

All posts

You see mysql error 1874 when the InnoDB storage engine runs in read-only mode. To fix it, enable write mode in your settings and restore disk write permissions. MySQL maps this issue to ER_INNODB_READ_ONLY under SQLSTATE HY000. The server returns the message that InnoDB is in read only mode. While this block is active, the engine rejects every insert, update, and delete query. Your apps can still read rows, which hides the problem until a write runs. Root causes of mysql error 1874 in the st

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 1874 when the InnoDB storage engine runs in read-only mode. To fix it, enable write mode in your settings and restore disk write permissions.

MySQL maps this issue to ER_INNODB_READ_ONLY under SQLSTATE HY000. The server returns the message that InnoDB is in read only mode. While this block is active, the engine rejects every insert, update, and delete query. Your apps can still read rows, which hides the problem until a write runs.

Root causes of mysql error 1874 in the storage engine

This failure starts inside the InnoDB storage layer, not the upper server layer. MySQL has a global read-only setting and a separate InnoDB read-only setting. Error 1874 triggers when the InnoDB engine itself locks out all write tasks. A startup rule often puts the engine into this state on purpose. Teams use this mode when running databases on read-only media or shared storage.

File system problems also force the engine into this locked state at boot. If the Linux user running MySQL lacks write rights on data files, InnoDB adapts. It may open the tables in read-only mode or fail to start. A crashed disk or a broken cloud volume can also remount as read-only. When the host OS blocks disk writes, InnoDB cannot update its transaction logs.

Cluster changes and replica setups are another frequent cause of this error. A read replica might have engine-level write locks set in its startup file. If an app sends writes to a replica by mistake, error 1874 appears. After a failover, a promoted node might keep its old startup file. That file keeps the engine locked even though the node is now primary.

How to diagnose and fix the failure safely

Start your check by confirming which database host the app is hitting. Make sure your routing tier points write traffic to the true primary node. If the app hits a read replica, update the host address right away. Do not manage a replica just to make an app error go away. Writing to a replica breaks data sync across your cluster.

Next, check the startup file on the primary database server. Look for the rule that sets the InnoDB engine to read-only mode. Because this rule applies at boot, you cannot change it while MySQL runs. You must remove or disable the read-only rule in the settings file. Then schedule a brief maintenance window to restart the MySQL service cleanly.

Read-Only Root Filesystem + MySQL Access Governance: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Before you restart the service, check the host file system and disk health. Verify that the MySQL system user owns the data folder and log files. Grant standard read and write rights to the MySQL user only. Never grant full public write rights to everyone on the server. Check system logs to confirm the disk is mounted for both reads and writes.

How to prevent write lock surprises in production

Keep your primary and replica startup files under strict version control. When you promote a replica to primary, use a clean startup file. This step ensures the new primary starts with full InnoDB write support. Monitor disk space and mount status so OS faults never surprise your team.

Use role-based controls for engineers who run manual database checks and fixes. Give read-only roles to users who only need to inspect data. Require peer approval before anyone runs write queries or alters server settings. Also apply data masking to rewrite emails, phone numbers, and card numbers in results.

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_INNODB_READ_ONLY mean in MySQL?

ER_INNODB_READ_ONLY is the official symbol for MySQL error code 1874 under SQLSTATE HY000. It means the InnoDB storage engine is in read-only mode and rejects writes.

Can I fix mysql error 1874 without restarting the database?

If the error comes from the InnoDB read-only startup rule, you must restart MySQL. If your app just connects to a replica by mistake, reroute the app instead.

How is InnoDB read-only mode different from global read-only mode?

Global read-only mode blocks writes across the server but allows admin changes at runtime. InnoDB read-only mode locks the storage engine at boot and blocks all table writes.

The query runs. The emails stay hidden.