Common SQL Errors

MySQL Error 1175: ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE - Fix, Causes, Prevention

Galaxy Team
August 6, 2025

MySQL Error 1175 occurs in safe-update mode when an UPDATE or DELETE lacks a WHERE clause referencing an indexed key column, blocking potentially destructive bulk changes.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 1175 ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE?

MySQL Error 1175: ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE triggers when safe-update mode blocks an UPDATE or DELETE without a key-based WHERE clause. Add a keyed filter or temporarily disable safe-update mode to resolve the issue.

Error Highlights

Typical Error Message

You are using safe update mode and you tried to update a

Error Type

Safety Mode Error

Language

MySQL

Symbol

ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE

Error Code

1175

SQL State

HY000

Explanation

Table of Contents

What is MySQL Error 1175 (ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE)?

MySQL raises error 1175 when the session variable SQL_SAFE_UPDATES is ON and an UPDATE or DELETE statement lacks a WHERE condition that filters on a primary key or indexed column.

The server aborts the statement to protect data from an unintended mass change.

The message usually reads: “You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column.” Fixing it quickly keeps production data safe and your deployment moving.

What Causes This Error?

Safe-update mode is enabled at the client or session level by starting the MySQL client with --safe-updates or running SET SQL_SAFE_UPDATES = 1;.

This flips on strict protections.

When safe mode is active, MySQL checks UPDATE and DELETE commands. If the WHERE clause is missing or does not reference a keyed column, the engine throws error 1175 and cancels execution.

How to Fix MySQL Error 1175

The safest fix is to rewrite the statement to include a WHERE clause that uses a primary key or indexed column.

This keeps safe-update mode on and fulfils the protection rule.

If a keyed WHERE is impractical, disable safe-update mode for the current session: SET SQL_SAFE_UPDATES = 0;. Re-enable it afterward to restore protection.

Common Scenarios and Solutions

Bulk clean-up scripts commonly fail when developers forget to filter by an indexed ID. Adding WHERE id > 0 if id is indexed passes the safe-mode check.

GUI tools like MySQL Workbench enable safe mode by default.

Temporarily uncheck “Safe Updates” in preferences or execute the SQL shown above before running maintenance jobs.

Best Practices to Avoid This Error

Always test destructive statements with SELECT first, then convert to UPDATE/DELETE. Include LIMIT clauses during development.

Use transactions so you can roll back mistakes, and keep safe-update mode enabled in production to guard data integrity.

Galaxy’s SQL editor flags missing indexed filters before execution, reducing risk.

Related Errors and Solutions

Error 1137 (HY000) happens when no matching rows are found for update in CI-based constraints. Unlike 1175, it is not tied to safe-update mode but to foreign-key checks.

Error 1205 (Lock wait timeout exceeded) may appear after disabling safe mode and executing long-running updates; reducing batch size or adding indexes resolves it.

.

Common Causes

Related Errors

FAQs

How do I check if safe-update mode is enabled?

Run SELECT @@SQL_SAFE_UPDATES;. A result of 1 means safe-update mode is on.

Can I disable safe-update mode permanently?

Add sql_safe_updates = 0 in the [mysqld] section of my.cnf and restart MySQL, but keep it on in production for safety.

Does LIMIT satisfy safe-update mode?

No. LIMIT alone is insufficient. The WHERE clause must reference an indexed key, or safe-update mode will still block the query.

How does Galaxy help avoid this error?

Galaxy’s linter warns users when UPDATE or DELETE statements lack indexed filters. It can auto-suggest key columns, preventing error 1175 before execution.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo