How to fix ERROR 1175: Safe update without WHERE on key in MySQL

MySQLBEGINNERMEDIUMUpdated Dec 23, 2025· 234 views

ERROR 1175 occurs when safe update mode is enabled and you try to UPDATE or DELETE rows without specifying a WHERE clause on a key column. Disable safe updates, add a proper WHERE clause, or use LIMIT to fix this.

Quick fix

Fixes 1175

SHOW VARIABLES LIKE 'sql_safe_updates';
  1. Check if safe updates mode is enabled
  2. Add a WHERE clause with a key column (recommended)
  3. Use LIMIT if you cannot use WHERE
  4. Temporarily disable safe updates for your session
mysql — error
SHOW VARIABLES LIKE 'sql_safe_updates';
ERROR 1175: Safe update without WHERE on key

What this error means

ERROR 1175 is a safety mechanism in MySQL that prevents accidental updates or deletions of entire tables. When SQL_SAFE_UPDATES mode is enabled (common in MySQL Workbench and some client tools), MySQL requires that UPDATE and DELETE statements must either: 1. Include a WHERE clause that references a key column (primary key or unique index) 2. Include a LIMIT clause to restrict the number of rows affected 3. Have safe updates mode explicitly disabled This error is intentionally restrictive to protect you from data loss. Without this protection, a forgotten WHERE clause could silently delete or update every row in a table.

Typical symptoms

  • UPDATE or DELETE statements fail with "ERROR 1175"
  • Error message includes "You are using safe update mode"
  • Happens when running queries in MySQL Workbench or CLI clients
  • Queries that work on another database suddenly fail

Common causes

  1. SQL_SAFE_UPDATES mode is enabled in your MySQL client or session (default in MySQL Workbench)
  2. Your UPDATE or DELETE statement lacks a WHERE clause entirely
  3. Your WHERE clause does not reference a key column (primary key or unique index)
  4. The optimizer decides not to use the index even though a key is specified

How to fix "ERROR 1175: Safe update without WHERE on key"

1Check if safe updates mode is enabled

Run this query to see the current setting:

sql
SHOW VARIABLES LIKE 'sql_safe_updates';

If the value is ON or 1, safe updates are enabled.

2Add a WHERE clause with a key column (recommended)

Modify your UPDATE or DELETE statement to include a WHERE clause that filters by a primary key or unique index:

sql
-- Instead of this (will fail):
UPDATE users SET status = 'active';

-- Use this (specifies key column):
UPDATE users SET status = 'active' WHERE id = 123;

-- Or for multiple rows:
UPDATE users SET status = 'active' WHERE department_id = 5;

Replace id with your table's primary key column name.

3Use LIMIT if you cannot use WHERE

If you need to update rows without a specific key condition, add a LIMIT clause:

sql
-- Update the first 100 unprocessed records
UPDATE tasks SET processed = 1 WHERE status = 'pending' LIMIT 100;

-- Delete old archived records
DELETE FROM logs WHERE created_at < DATE_SUB(NOW(), INTERVAL 30 DAY) LIMIT 1000;

LIMIT restricts the number of rows affected, preventing accidental mass updates.

4Temporarily disable safe updates for your session

If you absolutely need to update all rows, disable safe mode for that query:

sql
SET SQL_SAFE_UPDATES = 0;

-- Now you can run your UPDATE or DELETE without restrictions
UPDATE users SET status = 'active';
DELETE FROM old_data;

-- Re-enable it immediately afterward
SET SQL_SAFE_UPDATES = 1;

This disables the safety check only for your current session.

5Disable safe updates in MySQL Workbench (if using GUI)

If you're using MySQL Workbench and want to disable safe updates permanently:

1. Go to Edit → Preferences (Windows) or MySQL Workbench → Preferences (Mac)
2. Click the SQL Editor tab
3. Uncheck "Safe Updates (reject UPDATEs and DELETEs with no restrictions)"
4. Click OK and reconnect to the database

Note: This disables the protection globally for all your queries in Workbench, so be extra careful.

Advanced notes

When to keep safe updates enabled (recommended):
Safe updates mode is a valuable safeguard, especially in production environments. Most experienced developers keep it enabled and write proper WHERE clauses. This prevents the catastrophic mistake of running DELETE FROM users; when you meant DELETE FROM users WHERE id = 123;.

Optimizer ignoring indexes:
In rare cases, MySQL may refuse to use an index even if a key column is in your WHERE clause. This happens when:
- The estimated memory usage exceeds range_optimizer_max_mem_size (causes table scan instead of index scan)
- The optimizer estimates the scan would examine too many rows

In these cases, you can use LIMIT or explicitly disable safe updates for that query.

Comparison with other databases:
PostgreSQL doesn't have built-in safe update mode, but it's good practice to always use WHERE clauses regardless of database. Other tools like pgAdmin may offer similar safety features.

Safe updates in production:
Enable SQL_SAFE_UPDATES in all production environments and scripts. The slight inconvenience of writing explicit WHERE clauses is worth the protection against data loss.

Frequently asked questions

What does "1175" mean?
ERROR 1175 is a safety mechanism in MySQL that prevents accidental updates or deletions of entire tables. When SQL_SAFE_UPDATES mode is enabled (common in MySQL Workbench and some client tools), MySQL requires that UPDATE and DELETE statements must either: 1. Include a WHERE clause that references a key column (primary key or unique index) 2.
How do I fix "1175"?
ERROR 1175 occurs when safe update mode is enabled and you try to UPDATE or DELETE rows without specifying a WHERE clause on a key column. Disable safe updates, add a proper WHERE clause, or use LIMIT to fix this.
What causes "1175"?
SQL_SAFE_UPDATES mode is enabled in your MySQL client or session (default in MySQL Workbench) Your UPDATE or DELETE statement lacks a WHERE clause entirely Your WHERE clause does not reference a key column (primary key or unique index)
Is the "1175" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading