How to Fix MySQL Error 1036 (ER_OPEN_AS_READONLY)

Published
Length
3 min read

Luis Felipe Dias

All posts

A mysql error 1036 occurs when the database engine tries to modify a read-only table. You can fix it by restoring file ownership, clearing locks, or updating server read-only settings. This failure uses the official symbol ER_OPEN_AS_READONLY and returns the SQLSTATE code HY000. The server returns a message stating that the target table is read only. Your app can still read data, but all write queries will fail right away. What causes mysql error 1036 in your database Several issues at the s

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.

A mysql error 1036 occurs when the database engine tries to modify a read-only table. You can fix it by restoring file ownership, clearing locks, or updating server read-only settings.

This failure uses the official symbol ER_OPEN_AS_READONLY and returns the SQLSTATE code HY000. The server returns a message stating that the target table is read only. Your app can still read data, but all write queries will fail right away.

What causes mysql error 1036 in your database

Several issues at the storage or engine level can trigger a mysql error 1036. The most common cause is wrong file permissions on the host operating system. If the database process does not own the data files, it opens them as read-only.

This problem happens often after a team restores a backup or moves table files by hand. A root user might copy files into the data folder and forget to change the owner. When the service restarts, it cannot write to those files and throws the error.

Storage engine rules can also cause this error during daily operations. Compressed tables in older storage engines do not accept new writes by design. Once you compress those tables, the engine marks them as read-only forever.

In cloud or cluster setups, a node might enter a read-only state during maintenance. A disk error can also force the operating system to mount the storage volume as read-only. When the disk locks up, the database engine blocks table changes to stop data loss.

How to diagnose and fix the read-only state

Start your check by looking at the server error log for disk or file warnings. Next, check the operating system mount status to make sure the disk allows writes. If the disk is healthy, check the file owner inside the database storage directory.

Make sure the dedicated database user account owns every folder and table file. Avoid granting broad read and write access to all system users on the host. Setting wide file permissions creates a huge security risk for your production data.

Authorization as a Service + Open Policy Agent (OPA): architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Instead, assign strict ownership to the service account and limit access for other local users. After you fix the file owner, tell the database to reload its open tables. A table flush closes the locked files and reopens them with the right write access.

If the table uses a compressed format, you must uncompress it or change its storage engine. You can also copy the data into a fresh table that uses a standard engine. Always test these changes on a staging server before you run them in production.

How to prevent read-only table errors

Most read-only table errors happen when people run manual tasks on the database host. When engineers log in to move files or run ad-hoc queries, small mistakes happen. You can stop these errors by automating your backup and restore steps.

Set up your deployment scripts to check file owners every time a restore finishes. Keep human users off the raw host file system whenever you can. Route all database changes through a single control point that checks roles and logs every action.

Good access controls also protect your sensitive records during maintenance work. For example, data masking rewrites matched fields like emails and card numbers in query results. This approach lets your team check table health while keeping private data safe.

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

ER_OPEN_AS_READONLY is the official symbol for error code 1036 under SQLSTATE HY000. It means the server opened the table without write access, so changes will fail.

Do I need to restart the database after fixing file permissions?

No, a full server restart is not always needed after you fix file ownership. You can flush the tables so the engine closes and reopens the files with write access.

Why does a restored table trigger error 1036?

Restored tables often belong to the root account that ran the file copy task. Until you change the file owner back to the database user, the table stays read-only.

The query runs. The emails stay hidden.