If a legacy import fails on '0000-00-00' or a default such as '2012-00-00', the database is usually telling you something useful: the schema or dump still depends on old MySQL behavior. That often shows up during host moves, CMS upgrades, vendor handovers, or rushed staging restores. The wrong reaction is to weaken the whole server first and investigate later. The better approach is to confirm what mode the import is running under, identify which tables still use zero dates, and decide whether you need a one-off compatibility bridge or a real schema cleanup.
Why this happens on newer MySQL setups
Current MySQL defaults include strict validation plus the zero-date checks NO_ZERO_IN_DATE and NO_ZERO_DATE. MySQL still documents zero dates and partial zero dates as legacy-compatible values, but the separate mode names are deprecated and are expected to disappear as standalone switches in a future release. In plain English: older applications may still expect dummy dates, but modern MySQL treats that expectation as technical debt, not a safe default.
That matters for business owners, operations leads, and agency teams because the failure is often not in the import tool itself. It is usually in an old table definition, a dump exported from a permissive server, or application logic that used zero dates instead of NULL or a valid business date.
Check the active SQL mode before changing anything
Start by checking both the session and global values. Session scope is what affects the connection actually running your import.
SHOW SESSION VARIABLES LIKE 'sql_mode';
SHOW GLOBAL VARIABLES LIKE 'sql_mode';
SELECT @@SESSION.sql_mode, @@GLOBAL.sql_mode;
If the import is failing in a client you already opened, the session value is the one that matters first. This is where the old one-line fix is incomplete: SET GLOBAL does not change the current session, and it affects only new connections. You can change the global value, rerun an import in the same client, and still hit the same error.
Next, find the columns that still carry zero-date defaults so you know whether this is a one-table cleanup or a broader legacy pattern:
SELECT TABLE_NAME, COLUMN_NAME, COLUMN_TYPE, COLUMN_DEFAULT
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'your_database'
AND DATA_TYPE IN ('date','datetime','timestamp')
AND COLUMN_DEFAULT IN ('0000-00-00', '0000-00-00 00:00:00');
If this query returns a short list, you probably have a manageable schema issue. If it returns dozens of hits across an inherited application, treat the import error as part of a migration plan, not a quick console tweak.
The best long-term fix is usually schema and data cleanup
If you control the application, the cleanest solution is to remove impossible defaults and make the business rule explicit. In many systems that means using NULL for “unknown yet,” or storing a real date only when the business event actually happened.
A typical pattern looks like this:
ALTER TABLE your_table
MODIFY your_date_column DATE NULL DEFAULT NULL;
Use the matching data type for your real column, and test the application after the change. Legacy code sometimes assumes that '0000-00-00' means “not set,” so the database fix may need a small application fix beside it. That is still better than carrying an undocumented server-wide exception into the next upgrade or hosting move.
The safer short-term workaround for an urgent import
If you need to restore a legacy dump today and cannot clean the schema first, use a session-level change instead of a global one. This keeps the exception narrow and avoids changing behavior for other applications on the same MySQL instance.
SET SESSION sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
This is the safer equivalent of the original advice because it removes the zero-date checks only for the connection doing the import. Run the import from that same client session. If your environment already uses additional custom SQL modes, do not blindly copy a generic list; build the session value from what your server is actually using now.
For teams managing client estates, this is the practical rule: use a session-level compatibility bridge for a one-off rescue, and reserve server-wide changes for environments you fully own and test.
When a global or persistent change is justified
Sometimes the application really does depend on zero dates, and you need a server-wide temporary exception while a legacy platform is being retired. In that case, make it a controlled infrastructure decision. Document why it exists, who depends on it, and when it should be removed. Session changes are usually possible without special privileges; global or persisted changes require elevated privileges.
If you need the setting to survive restarts, MySQL supports persistent system variable changes. SET GLOBAL alone does not make a change permanent. The key point is that a lasting change should come from an owned runbook, not from a forgotten troubleshooting command pasted into production during a tense migration window.
A practical decision rule
- If one import is blocked and the application is otherwise being phased out, use a session-level change and complete the restore.
- If the same issue appears during every deployment, export, or refresh, fix the schema and application handling rather than normalizing the exception.
- If multiple teams or client sites share the same MySQL server, avoid casual global changes because they can alter future connections for unrelated workloads.
- If you are planning a replatform, CMS upgrade, or vendor handover, audit zero dates early. They are often a sign of larger legacy assumptions that will surface again.
When this issue shows up in the middle of a migration, it is rarely just a database error. It is usually a small example of a bigger ownership problem: old application assumptions meeting newer infrastructure defaults.
If you want that cleaned up without turning it into a risky launch-week surprise, Greg can help scope the database cleanup, import path, and rollout plan.
Need help with this kind of work?
Need a safe MySQL import, cleanup, or migration plan for a legacy site? Talk with Greg. Get in touch with Greg.
Sources
- MySQL 8.4 Reference Manual :: 7.1.11 Server SQL Modes
- MySQL 9.1 Reference Manual :: 15.7.6.1 SET Syntax for Variable Assignment
- MySQL 9.7 Reference Manual :: 13.2 Date and Time Data Types
- MySQL 9.7 Reference Manual :: 15.7.7.42 SHOW VARIABLES Statement
- MySQL 9.7 Reference Manual :: 28.3.8 The INFORMATION_SCHEMA COLUMNS Table