1290
MySQLERRORNotableModeHIGH confidence

Statement not allowed — read-only or safe-update mode active

What this means

ER_OPTION_PREVENTS_STATEMENT (1290) is returned when a statement is blocked by a server option — most commonly --read-only mode blocking writes, or --safe-updates blocking UPDATE/DELETE without a WHERE clause.

How to reproduce
trigger — this will error
trigger — this will error
-- With --safe-updates:
UPDATE users SET status = 'active';
-- ERROR 1290 (HY000): The MySQL server is running with the --safe-updates option

expected output

ERROR 1290 (HY000): The MySQL server is running with the --safe-updates option so it cannot execute this statement

Fix 1

Add a WHERE clause (safe-updates mode)

WHEN When safe-updates mode is preventing UPDATE/DELETE.

Add a WHERE clause (safe-updates mode)
-- Add a proper WHERE clause
UPDATE users SET status = 'active' WHERE created_at < '2024-01-01';

-- Or disable safe-updates for the session:
SET SQL_SAFE_UPDATES = 0;
UPDATE users SET status = 'active';
SET SQL_SAFE_UPDATES = 1;

Why this works

safe-updates requires UPDATE and DELETE to use a WHERE clause or LIMIT. Adding a WHERE clause is the correct fix.

Fix 2

Connect to a read-write replica or disable read-only

WHEN When read-only mode is preventing writes.

Connect to a read-write replica or disable read-only
-- Check read-only status:
SHOW VARIABLES LIKE 'read_only';
-- Disable for the session (requires SUPER):
SET GLOBAL read_only = OFF;

Why this works

read-only mode is set on replicas or for maintenance. Writes should target the primary/read-write node.

What not to do

Permanently disable SQL_SAFE_UPDATES in production

Safe-updates mode prevents accidental full-table UPDATE/DELETE; it should be kept enabled and fixed at the query level instead.

Sources
Official documentation ↗

MySQL 8.0 — 1290 ER_OPTION_PREVENTS_STATEMENT

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

← All MySQL errors