1036
MariaDBERRORNotableDMLHIGH confidence

Table is read only

Production Risk

Medium — writes are blocked; typical on replicas by design.

What this means

ER_OPEN_AS_READONLY (1036, SQLSTATE HY000) is raised when a write operation (INSERT, UPDATE, DELETE) is attempted on a table that has been opened as read-only, either because the server is in read_only mode or the table files are read-only on disk.

Why it happens
  1. 1Server has read_only or super_read_only enabled (common on replicas)
  2. 2Table data files have OS-level read-only permissions
  3. 3Table is a TEMPORARY table opened on a read-only tablespace
How to reproduce
trigger — this will error
trigger — this will error
SET GLOBAL read_only = ON;
INSERT INTO t VALUES (1);

expected output

ERROR 1036 (HY000): Table 't' is read only

Fix 1

Disable read_only on the server if appropriate

WHEN You intended to write to this server and read_only was set by mistake.

Disable read_only on the server if appropriate
SET GLOBAL read_only = OFF;

Why this works

read_only prevents non-SUPER users from modifying data; disabling it restores normal write access.

Fix 2

Fix OS file permissions on the table files

WHEN The table data files are read-only at the OS level.

Fix OS file permissions on the table files
-- From OS shell:
-- chmod 660 /var/lib/mysql/dbname/tablename.*
-- chown mysql:mysql /var/lib/mysql/dbname/tablename.*

Why this works

MySQL needs read-write access to the .ibd (InnoDB) or .MYD/.MYI (MyISAM) files to perform writes.

What not to do

Disable read_only on a replica to allow direct writes

Writing directly to a replica bypasses replication and causes the replica to diverge from the source.

Sources
Official documentation ↗

MySQL 8.0 — 1036 ER_OPEN_AS_READONLY

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MariaDB errors