mysqldude
Error codes › 1067

MySQL & MariaDB error 1067: Invalid default value

Error messageInvalid default value for '…'
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.

MySQLMariaDB
SymbolER_INVALID_DEFAULTER_INVALID_DEFAULT
SQLSTATE4200042000
TypeServer errorServer error
Versionsevery release since 5.0 activeevery 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' with NO_ZERO_DATE (or NO_ZERO_IN_DATE) plus strict mode. MySQL 5.7 made those modes part of the default sql_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 TIMESTAMP column created before MySQL 5.6.5/5.7 relied on the implicit DEFAULT '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 an ENUM list, or a number too long for the column.
  • BLOB/TEXT/JSON columns 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_TIMESTAMP for creation times, or make the column NULL DEFAULT NULL if “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.

  1. Connect with mysql -u root -p and create a scratch database:

    CREATE DATABASE demo;
    USE demo;
  2. 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

  1. 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

StepMySQLMariaDB
5.65.78.08.4910.610.1111.411.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'

Related errors

  • 1292 ER_TRUNCATED_WRONG_VALUEexplained
  • 1101 ER_BLOB_CANT_HAVE_DEFAULT
  • 1264 ER_WARN_DATA_OUT_OF_RANGEexplained