Common SQL Errors

MySQL Error 3135: ER_SQL_MODE_MERGED - How to Fix and Prevent

Galaxy Team
August 8, 2025

Error 3135 is raised when NO_ZERO_DATE, NO_ZERO_IN_DATE, or ERROR_FOR_DIVISION_BY_ZERO sql modes are enabled without strict mode, which is disallowed in MySQL 5.7.8 and later.

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 code 3135 ER_SQL_MODE_MERGED?

MySQL error 3135 (ER_SQL_MODE_MERGED) occurs when NO_ZERO_DATE, NO_ZERO_IN_DATE, or ERROR_FOR_DIVISION_BY_ZERO are set without STRICT_TRANS_TABLES or STRICT_ALL_TABLES. Add a strict mode or remove the standalone flags to resolve the issue.

Error Highlights

Typical Error Message

ER_SQL_MODE_MERGED

Error Type

Configuration Error

Language

MySQL

Symbol

ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. ER_SQL_MODE_MERGED was added in 5.7.8.

Error Code

3135

SQL State

HY000

Explanation

Table of Contents

What is MySQL Error 3135 (ER_SQL_MODE_MERGED)?

MySQL raises error 3135 when you enable NO_ZERO_DATE, NO_ZERO_IN_DATE, or ERROR_FOR_DIVISION_BY_ZERO in sql_mode without also enabling STRICT_TRANS_TABLES or STRICT_ALL_TABLES.

The server blocks this mix because those checks will be folded into strict mode in future versions, and running them separately would cause upgrade inconsistencies.

The error is triggered at server startup, during SET sql_mode statements, or when a session inherits an invalid mode list.

Resolving it immediately ensures reliable data validation and smoother version upgrades.

What Causes This Error?

The primary cause is a sql_mode string that lists one of the legacy flags but omits any strict mode option.

Such strings often originate from old configuration files, application‐level overrides, or connection strings in database libraries.

Starting with MySQL 5.7.8, the server validates sql_mode on every assignment and throws ER_SQL_MODE_MERGED if the combination is unsafe.

How to Fix ER_SQL_MODE_MERGED

Include STRICT_TRANS_TABLES or STRICT_ALL_TABLES alongside the legacy flags, or remove the legacy flags entirely because strict mode already enforces their behavior.

Apply the change globally in my.cnf or instantly at session level using SET sql_mode.

Common Scenarios and Solutions

Server fails to start due to NO_ZERO_DATE in my.cnf. Add STRICT_TRANS_TABLES and restart to clear the error.

An ORM issues SET SESSION sql_mode='NO_ZERO_IN_DATE'. Replace the statement with SET SESSION sql_mode='STRICT_TRANS_TABLES' in the ORM configuration.

A CI pipeline imports dumps that set forbidden modes. Update the dump scripts to use a strict mode list before deployment.

Best Practices to Avoid This Error

Always pair strict mode with any legacy validation flags when editing sql_mode.

Centralize sql_mode management in version‐controlled configuration files to prevent environment drift.

Verify sql_mode with SELECT @@GLOBAL.sql_mode in staging during upgrades and resolve warnings before production rollout.

Related Errors and Solutions

ER_TRUNCATED_WRONG_VALUE (1292) appears when strict mode blocks invalid date inserts. Correct the input data.

ER_UNKNOWN_SYSTEM_VARIABLE (1193) is triggered by misspelled sql_mode flags. Check spelling against supported modes for your MySQL version.

Common Causes

Legacy sql_mode copied from older versions

Configurations migrated from MySQL 5.6 often list NO_ZERO_DATE or NO_ZERO_IN_DATE without strict mode, leading to error 3135 after upgrade.

Application level SET statements

Frameworks or ORMs may explicitly set sql_mode to NO_ZERO_DATE expecting old behavior, which modern servers reject.

Session overrides in connection strings

Database connectors that allow sql_mode parameters can trigger ER_SQL_MODE_MERGED when strict mode is omitted.

Related Errors

Error 1292 - ER_TRUNCATED_WRONG_VALUE

Appears when strict mode rejects invalid dates or numbers. Validate and correct incoming data.

Error 1364 - ER_NO_DEFAULT_FOR_FIELD

Occurs under strict mode when a required column is omitted. Provide a value or set a default.

Error 1193 - ER_UNKNOWN_SYSTEM_VARIABLE

Raised when a nonexistent sql_mode flag is supplied. Verify the flag name and MySQL version.

FAQs

Does ER_SQL_MODE_MERGED damage my data?

No. The server simply rejects the invalid sql_mode assignment. Data and schema remain untouched.

Can I disable strict mode instead?

You can, but you lose valuable data validation. It is safer to keep strict mode and drop the redundant flags.

Which strict mode should I use?

STRICT_TRANS_TABLES is recommended for most workloads as it validates per row, while STRICT_ALL_TABLES rolls back entire statements on error.

Is this error shown in MySQL 5.6?

No. The validation was introduced in 5.7.8. Upgrading exposes the misconfiguration so you can address it sooner.

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