How to Turn Off Safe Update Mode in MySQL
Robert Cooper
Robert Cooper Senior Engineer at Basedash
· January 31, 2025
Robert Cooper
Robert Cooper Senior Engineer at Basedash
· January 31, 2025
When working with MySQL, you might encounter a situation where you’re restricted by the safe update mode. This guide explains how to disable this mode, which is often encountered in MySQL Workbench or other client interfaces, particularly when trying to execute update or delete operations without a WHERE clause or with a non-key column in WHERE.
Safe update mode in MySQL is designed to prevent accidental updates or deletions of data. It requires that any UPDATE or DELETE operations include a WHERE clause that uses a key column or limits the number of rows affected.
To temporarily disable safe update mode for your current session, you can use the following SQL command:
SET SQL_SAFE_UPDATES = 0;
This command sets the SQL_SAFE_UPDATES variable to 0, effectively turning off the safe update mode. Remember, this change is temporary and only applies to the current session.
If you’re using MySQL Workbench and want to disable the safe update mode:
After completing these steps, MySQL Workbench will no longer enforce safe update mode for any new sessions.
For a more permanent solution, you can modify the MySQL configuration file:
Locate your MySQL configuration file, typically named my.cnf or my.ini.
Open the file in a text editor.
In the [mysqld] section, add the following line:
sql_safe_updates=0
Save the file and restart the MySQL server for the changes to take effect.
This change will disable safe update mode for all connections to the MySQL server.
If you prefer using the command line, you can start the MySQL server with the --sql_safe_updates=0 option:
mysqld --sql_safe_updates=0
This approach is useful for temporary changes or for testing purposes.
Disabling safe update mode removes a layer of protection against accidental data modification. It’s important to be cautious with your UPDATE and DELETE statements, especially when working without a WHERE clause.
Written by
Senior Engineer at Basedash
Robert Cooper is a senior engineer at Basedash who builds full-stack product systems across SQL data infrastructure, APIs, and frontend architecture. His work focuses on application performance, developer velocity, and reliable self-hosted workflows that make data operations easier for teams at scale.
Basedash lets you build charts, dashboards, and reports in seconds using all your data.