MySQL error code, 1175 during UPDATE in MySQL Workbench
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
MySQL error code 1175 means you tried to run an UPDATE or DELETE statement without a WHERE clause that references a KEY column while safe update mode is active. This is a safety feature, not a bug. You can fix it by adding a key column to your WHERE clause, temporarily disabling safe updates with SET SQL_SAFE_UPDATES = 0, or turning off safe updates in MySQL Workbench preferences.
What Triggers Error Code 1175?
The full error message reads:
MySQL's safe update mode (sql_safe_updates) prevents UPDATE and DELETE statements that could accidentally modify every row in a table. It is enabled by default in MySQL Workbench's interactive SQL editor.
The mode blocks a query when any of these conditions are true:
- The statement has no WHERE clause at all
- The WHERE clause does not reference a column with a primary key or unique index
- The WHERE clause references only non-indexed columns
- The UPDATE uses a LIMIT but still has no key-based WHERE
Three Ways to Fix Error 1175
Fix 1: Add a Key Column to Your WHERE Clause (Recommended)
The safest fix is to rewrite your query so the WHERE clause references a primary key or indexed column:
The WHERE order_id > 0 trick satisfies the safe update check while still applying your actual filter. Use this when you genuinely need to update many rows but want to keep safe mode active.
Fix 2: Temporarily Disable Safe Updates in Your Session
If you need to run a bulk update and adding a key column is impractical, disable safe updates for the duration of your operation:
This change only affects your current session and resets when you disconnect.
Fix 3: Disable Safe Updates in MySQL Workbench Preferences
To permanently disable safe updates in MySQL Workbench:
- Go to Edit then Preferences (or MySQLWorkbench then Preferences on macOS)
- Select SQL Editor in the left panel
- Scroll to the bottom and uncheck Safe Updates (rejects UPDATEs and DELETEs with no restrictions)
- Click OK
- Close and reopen your connection tab (the setting takes effect on new connections)
This disables safe mode for all future sessions in Workbench.
Which Fix Should You Choose?
| Approach | Scope | Risk Level | Best For |
| Add key column to WHERE | Single query | Low | Production databases, targeted updates |
SET SQL_SAFE_UPDATES = 0 | Current session | Medium | One-time bulk operations, data migrations |
| Workbench Preferences | All sessions | Higher | Development environments only |
--safe-updates=0 (CLI flag) | CLI session | Medium | Scripted batch operations |
How Safe Update Mode Works Internally
The sql_safe_updates system variable controls this behavior. When enabled, MySQL checks the query plan before execution. It specifically looks for whether the optimizer can use an index to limit the affected rows.
You can check the current state of this variable:
The variable works in conjunction with two other variables that limit potentially dangerous queries:
Safe Updates with JOINs and Subqueries
Error 1175 also affects UPDATE and DELETE statements that use JOINs or subqueries. The key column requirement applies to the table being modified:
For DELETE with JOINs:
Error 1175 in Other MySQL Clients
Safe update mode is not exclusive to MySQL Workbench. Other clients and connection methods may also enable it:
In application code, you can control it per connection:
Common Pitfalls
- Forgetting to reconnect after changing Workbench preferences: The preference change only applies to new connections. You must close and reopen the query tab.
- Leaving safe updates permanently disabled in production: This removes a safety net that prevents accidental mass updates. Only disable it in development environments.
- Using
WHERE 1=1as a workaround: This does not satisfy the safe update check because1=1does not reference a key column. UseWHERE primary_key > 0instead. - Confusing
sql_safe_updateswithread_only:sql_safe_updatesonly blocks unqualified UPDATE/DELETE. It does not prevent all writes.read_onlyprevents all write operations from non-SUPER users. - Ignoring the LIMIT interaction: When
sql_safe_updatesis on, MySQL also limits SELECT results viasql_select_limit. This can cause unexpected result truncation in Workbench queries.
Summary
- Error 1175 fires when UPDATE or DELETE lacks a WHERE clause referencing a KEY column while
sql_safe_updatesis enabled. - The safest fix is adding a primary key or indexed column to your WHERE clause.
- Use
SET SQL_SAFE_UPDATES = 0for temporary bulk operations, and always re-enable it withSET SQL_SAFE_UPDATES = 1. - Permanently disabling safe updates in Workbench preferences is suitable for development but risky for production.
- The
WHERE primary_key > 0pattern satisfies the safe update check when you need to affect many rows. - Safe update mode also applies to JOINs and subqueries. The key column must reference the table being modified.

