MySQL 8.4Lab-verified · 2026-11-29

MySQL ERROR 1067 (42000): Invalid default value

The DEFAULT in CREATE TABLE is not a value the column can hold under the current sql_mode.

MySQL 8.4.13
1067 (42000): Invalid default value for 'created_at'

Jump to a cause

  1. 01DATETIME DEFAULT '0000-00-00 00:00:00' (NO_ZERO_DATE)
  2. 02TIMESTAMP default before 1970
  3. 03Default value does not fit the column (VARCHAR too short)

Lab-verifiedReproduced and fixed on MySQL 8.4.13 · 2026-11-29 · container image mysql:8.4

ERROR 1067 is raised by CREATE TABLE or ALTER TABLE when a column's DEFAULT value cannot be stored in that column. The message names the first bad column, for example Invalid default value for 'created_at'.

The runs below use MySQL 8.4 with the default sql_mode, which includes STRICT_TRANS_TABLES, NO_ZERO_IN_DATE and NO_ZERO_DATE. Old dumps from 5.x often fail here.

01DATETIME DEFAULT '0000-00-00 00:00:00' (NO_ZERO_DATE)

created_at DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' failed with ERROR 1067 for 'created_at'. SELECT @@sql_mode showed NO_ZERO_IN_DATE,NO_ZERO_DATE and STRICT_TRANS_TABLES, so a zero date is not accepted.

Changing the default to DEFAULT CURRENT_TIMESTAMP created the table, and an INSERT without created_at filled it automatically.

Reproducerun as lab_a
CREATE TABLE orders (id INT PRIMARY KEY, created_at DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00');
✕ ERROR
ERROR 1067 (42000): Invalid default value for 'created_at'
Checkrun as lab_a
SELECT @@sql_mode;
OUTPUT
+-----------------------------------------------------------------------------------------------------------------------+
| @@sql_mode                                                                                                            |
+-----------------------------------------------------------------------------------------------------------------------+
| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |
+-----------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

If the column means "not set yet", allowing NULL instead of a zero date is another option, but only CURRENT_TIMESTAMP was tested here.

After the fixrun as lab_a
CREATE TABLE orders (id INT PRIMARY KEY, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP);
INSERT INTO orders (id) VALUES (1);
SELECT id, created_at IS NOT NULL AS has_created_at FROM orders;
✓ SUCCESS
Query OK, 0 rows affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

+----+----------------+
| id | has_created_at |
+----+----------------+
|  1 |              1 |
+----+----------------+
1 row in set (0.00 sec)

02TIMESTAMP default before 1970

birth_at TIMESTAMP DEFAULT '1960-01-01 00:00:00' failed with ERROR 1067 for 'birth_at'. TIMESTAMP stores Unix time, and UNIX_TIMESTAMP('1960-01-01 00:00:00') returned 0, while 1970-01-02 was a positive value.

Using DATETIME for the column kept the same default; the inserted row showed 1960-01-01 00:00:00.

Reproducerun as lab_a
CREATE TABLE members (id INT PRIMARY KEY, birth_at TIMESTAMP DEFAULT '1960-01-01 00:00:00');
✕ ERROR
ERROR 1067 (42000): Invalid default value for 'birth_at'
Checkrun as lab_a
SELECT UNIX_TIMESTAMP('1960-01-01 00:00:00') AS ts_1960, UNIX_TIMESTAMP('1970-01-02 00:00:00') > 0 AS ts_1970_ok;
OUTPUT
+---------+------------+
| ts_1960 | ts_1970_ok |
+---------+------------+
|       0 |          1 |
+---------+------------+
1 row in set (0.00 sec)
After the fixrun as lab_a
CREATE TABLE members (id INT PRIMARY KEY, birth_at DATETIME DEFAULT '1960-01-01 00:00:00');
INSERT INTO members (id) VALUES (1);
SELECT * FROM members;
✓ SUCCESS
Query OK, 0 rows affected (0.02 sec)

Query OK, 1 row affected (0.00 sec)

+----+---------------------+
| id | birth_at            |
+----+---------------------+
|  1 | 1960-01-01 00:00:00 |
+----+---------------------+
1 row in set (0.00 sec)

03Default value does not fit the column (VARCHAR too short)

status VARCHAR(5) DEFAULT 'active' failed with ERROR 1067 for 'status'. CHAR_LENGTH('active') is 6, one more than the column allows.

The table was created with status VARCHAR(10) DEFAULT 'active' and stock INT DEFAULT 0 (the original had DEFAULT 'none' on an INT column). The inserted row had status active and stock 0.

Reproducerun as lab_a
CREATE TABLE products (id INT PRIMARY KEY, status VARCHAR(5) DEFAULT 'active', stock INT DEFAULT 'none');
✕ ERROR
ERROR 1067 (42000): Invalid default value for 'status'
Checkrun as lab_a
SELECT CHAR_LENGTH('active') AS status_len;
OUTPUT
+------------+
| status_len |
+------------+
|          6 |
+------------+
1 row in set (0.00 sec)
After the fixrun as lab_a
CREATE TABLE products (id INT PRIMARY KEY, status VARCHAR(10) DEFAULT 'active', stock INT DEFAULT 0);
INSERT INTO products (id) VALUES (1);
SELECT * FROM products;
✓ SUCCESS
Query OK, 0 rows affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

+----+--------+-------+
| id | status | stock |
+----+--------+-------+
|  1 | active |     0 |
+----+--------+-------+
1 row in set (0.00 sec)

FAQ

How do I fix Invalid default value for 'created_at'?

Use a default the column can store. In the run above DEFAULT CURRENT_TIMESTAMP replaced '0000-00-00 00:00:00' and the table was created.

Why does my old dump fail with 1067 on MySQL 8?

The 8.x default sql_mode includes NO_ZERO_DATE and NO_ZERO_IN_DATE. Zero-date defaults in old dumps are rejected. Check with SELECT @@sql_mode;.

Can a TIMESTAMP column have a default before 1970?

No. In the second case a 1960 default failed on TIMESTAMP and worked on DATETIME.

The message names only one column — are others OK?

Not necessarily. MySQL reports the first bad column; check every DEFAULT in the statement.

How we verify

Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.

lab_a and lab_b are ordinary users created for the test, each with full rights on a database of the same name (its default database); root is the administrator. MySQL 8.4.13