Error codes › 1067
MySQL & MariaDB error 1067: Invalid default value
Example from our test runs:
Invalid default value for 'created' (5.6.51) A column DEFAULT the current sql_mode doesn't accept. Usually '0000-00-00' on a DATE/DATETIME/TIMESTAMP under NO_ZERO_DATE, which breaks old dumps on newer servers.
| MySQL | MariaDB | |
|---|---|---|
| Symbol | ER_INVALID_DEFAULT | ER_INVALID_DEFAULT |
| SQLSTATE | 42000 | 42000 |
| Type | Server error | Server error |
| Versions | every release since 5.0 active | every release since 5.5 active |
What it means
The DEFAULT given in CREATE TABLE or ALTER TABLE isn’t a valid value for the column under the session’s sql_mode. By far the most common case is a zero date.
Why it happens
created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'withNO_ZERO_DATE(orNO_ZERO_IN_DATE) plus strict mode. MySQL 5.7 made those modes part of the defaultsql_mode, so schemas and dumps from MySQL 5.5/5.6 or older applications fail to load on 5.7 and later.- Tested: with their default sql_mode, MySQL 5.6 and MariaDB 10.6–11.8 accept the zero-date default; MySQL 5.7, 8.0, 8.4 and 9.x reject it with 1067.
- A
TIMESTAMPcolumn created before MySQL 5.6.5/5.7 relied on the implicitDEFAULT '0000-00-00 00:00:00'for the second timestamp column of a table. - A default that doesn’t fit the type: a string default for an
INT, a value outside anENUMlist, or a number too long for the column. BLOB/TEXT/JSONcolumns with a literal default fail with a related error (1101) on servers that don’t support expression defaults.
How to fix it
- Use a real default:
DEFAULT CURRENT_TIMESTAMPfor creation times, or make the columnNULL DEFAULT NULLif “unknown” is allowed. - To load an old dump once and clean up afterwards, relax the mode for that session only:
SET SESSION sql_mode = REPLACE(REPLACE(@@sql_mode, 'NO_ZERO_DATE', ''), 'NO_ZERO_IN_DATE', '');. Then fix the column definitions and the zero dates in the data. - Don’t remove strict mode globally to make this go away: it also hides truncation and invalid data on every insert.
Reproduce it yourself
These steps are the exact test our harness runs. Use a scratch server, never production.
Connect with
mysql -u root -pand create a scratch database:CREATE DATABASE demo; USE demo;Run:
SET SESSION sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE'; CREATE TABLE t (created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00');
You get: Invalid default value for 'created'(11.8.9)
Verified fixes
Use a real default (CURRENT_TIMESTAMP) or allow NULL
SET SESSION sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE'; CREATE TABLE t (created DATETIME NULL DEFAULT NULL, updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP); INSERT INTO t () VALUES (); SELECT created IS NULL, updated IS NOT NULL FROM t;
Tested on
| Step | MySQL | MariaDB | |||||||
|---|---|---|---|---|---|---|---|---|---|
| 5.6 | 5.7 | 8.0 | 8.4 | 9 | 10.6 | 10.11 | 11.4 | 11.8 | |
| A zero-date default under the strict sql_mode that MySQL 5.7+ uses by default repro | ✓ 1067 | ✓ 1067 | ✓ 1067 | ✓ 1067 | ✓ 1067 | ✓ 1067 | ✓ 1067 | ✓ 1067 | ✓ 1067 |
| Does the old definition load with each server's default sql_mode? (MySQL 5.6 and MariaDB accept it) version check | ✓ | ✗ 1067 | ✗ 1067 | ✗ 1067 | ✗ 1067 | ✓ | ✓ | ✓ | ✓ |
| Use a real default (CURRENT_TIMESTAMP) or allow NULL fix | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
A zero-date default under the strict sql_mode that MySQL 5.7+ uses by default repro
MySQL 5.6✓ 10675.7✓ 10678.0✓ 10678.4✓ 10679✓ 1067
MariaDB 10.6✓ 106710.11✓ 106711.4✓ 106711.8✓ 1067
Does the old definition load with each server's default sql_mode? (MySQL 5.6 and MariaDB accept it) version check
MySQL 5.6✓5.7✗ 10678.0✗ 10678.4✗ 10679✗ 1067
MariaDB 10.6✓10.11✓11.4✓11.8✓
Use a real default (CURRENT_TIMESTAMP) or allow NULL fix
MySQL 5.6✓5.7✓8.0✓8.4✓9✓
MariaDB 10.6✓10.11✓11.4✓11.8✓
✓works ✓ 1062fails with the error the step demonstrates ⚠works with a warning ≠runs, result differs ✗fails Tested 2026-11-25 on 5.6.51, 5.7.44, 8.0.46, 8.4.13, 9.7.4, 10.6.28, 10.11.19, 11.4.13, 11.8.9
What the warnings and failures say (1)
- Does the old definition load with each server's default sql_mode? (MySQL 5.6 and MariaDB accept it) (MySQL 5.7, MySQL 8.0, MySQL 8.4, MySQL 9): error 1067: Invalid default value for 'created'