mysqldude
Error codes › 1175

MySQL & MariaDB error 1175: You are using safe update mode

MySQLYou are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. …
MariaDBYou are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
Example from our test runs: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. (5.7.44) · You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column (10.6.28)

sql_safe_updates is on, and the UPDATE or DELETE has no WHERE condition on a key column and no LIMIT. MySQL Workbench and `mysql --safe-updates` turn this on to stop accidental full-table changes.

MySQLMariaDB
SymbolER_UPDATE_WITHOUT_KEY_IN_SAFE_MODEER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE
SQLSTATEHY000HY000
TypeServer errorServer error
Versionsevery release since 5.0 activeevery release since 5.5 active

What it means

You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. Safe update mode refuses UPDATE and DELETE statements that could touch every row: no WHERE at all, or a WHERE that can’t use an index, and no LIMIT.

Why it happens

  • MySQL Workbench enables safe updates by default (Edit → Preferences → SQL Editor → “Safe Updates”), so a statement that works in your application fails in Workbench.
  • mysql --safe-updates (or --i-am-a-dummy) on the command line.
  • The WHERE filters on a non-indexed column (WHERE status = 'old').

How to fix it

  • Filter on a key: WHERE id = 2, or WHERE id IN (…) with literal ids.
  • Add a LIMIT (allowed even without a key condition): UPDATE t SET … WHERE status = 'old' LIMIT 1000;
  • If you really mean to change many rows: SET SESSION sql_safe_updates = 0;, run the statement, then switch it back on. In Workbench you can also untick the preference and reconnect.
  • Better still, index the column you filter on.

Reproduce it yourself

These steps are the exact test our harness runs. Use a scratch server, never production.

  1. Connect with mysql -u root -p and create a scratch database and the test data:

    CREATE DATABASE demo;
    USE demo;
    CREATE TABLE t (id INT PRIMARY KEY, status VARCHAR(10));
    INSERT INTO t VALUES (1,'new'),(2,'old');
  2. Run:

    SET SESSION sql_safe_updates = 1;
    UPDATE t SET status = 'done' WHERE status = 'old';

You get: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column(11.8.9)

Verified fixes

  1. Filter on a key column, or add a LIMIT

    SET SESSION sql_safe_updates = 1;
    UPDATE t SET status = 'done' WHERE id = 2;
    UPDATE t SET status = 'done' WHERE status = 'new' LIMIT 10;
    SELECT COUNT(*) FROM t WHERE status = 'done';
  2. Or switch safe updates off for this session only

    SET SESSION sql_safe_updates = 1;
    SET SESSION sql_safe_updates = 0;
    UPDATE t SET status = 'done' WHERE status = 'old';
    SELECT COUNT(*) FROM t WHERE status = 'done';

Tested on

StepMySQLMariaDB
5.65.78.08.4910.610.1111.411.8
sql_safe_updates is on (MySQL Workbench sets it) and WHERE doesn't use a key
repro
✓ 1175✓ 1175✓ 1175✓ 1175✓ 1175✓ 1175✓ 1175✓ 1175✓ 1175
Filter on a key column, or add a LIMIT
fix
✓✓✓✓✓✓✓✓✓
Or switch safe updates off for this session only
fix
✓✓✓✓✓✓✓✓✓
sql_safe_updates is on (MySQL Workbench sets it) and WHERE doesn't use a key repro
MySQL 5.6✓ 11755.7✓ 11758.0✓ 11758.4✓ 11759✓ 1175
MariaDB 10.6✓ 117510.11✓ 117511.4✓ 117511.8✓ 1175
Filter on a key column, or add a LIMIT fix
MySQL 5.6✓5.7✓8.0✓8.4✓9✓
MariaDB 10.6✓10.11✓11.4✓11.8✓
Or switch safe updates off for this session only fix
MySQL 5.6✓5.7✓8.0✓8.4✓9✓
MariaDB 10.6✓10.11✓11.4✓11.8✓
✓works ✓ 1062fails with the error the step demonstrates ⚠works with a warning ≠runs, result differs ✗fails Tested 2026-11-25 on 5.6.51, 5.7.44, 8.0.46, 8.4.13, 9.7.4, 10.6.28, 10.11.19, 11.4.13, 11.8.9

Related errors

  • 1205 ER_LOCK_WAIT_TIMEOUTexplained
How the message changed between versions
MySQL fromSymbolMessage
5.0.96ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODEYou are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
5.7.44ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODEYou are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. %s
8.0.11ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODEYou are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
8.0.16ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODEYou are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. %s