mysqldude
Error codes › 1364

MySQL & MariaDB error 1364: Field doesn't have a default value

Error messageField '…' doesn't have a default value
Example from our test runs: Field 'name' doesn't have a default value (5.6.51)

An INSERT left out a NOT NULL column that has no DEFAULT. In strict mode the row is rejected; without strict mode an implicit default ('' or 0) is used with a warning.

MySQLMariaDB
SymbolER_NO_DEFAULT_FOR_FIELDER_NO_DEFAULT_FOR_FIELD
SQLSTATEHY000HY000
TypeServer errorServer error
Versionsevery release since 5.0 activeevery release since 5.5 active

What it means

Field 'name' doesn't have a default value. Every column you don’t list in an INSERT gets its default. A NOT NULL column without a DEFAULT has none, so strict mode refuses the row. Without strict mode the server invents one (empty string, 0, or the zero date) and only warns, which is the behaviour code written for MySQL 5.6 often relied on.

Why it happens

  • Applications migrated from MySQL 5.6 (non-strict by default) to MySQL 5.7+ or MariaDB, which are strict by default.
  • A new NOT NULL column was added to a table but the application doesn’t fill it yet.
  • AUTO_INCREMENT was dropped from an id column during a migration.

How to fix it

  • Give the column a default: ALTER TABLE p ALTER name SET DEFAULT 'unknown'; (MySQL 8.0.13+ also allows expression defaults like DEFAULT (UUID())).
  • Or make it nullable, or have the application always supply it.
  • Avoid switching strict mode off globally: it hides this and other data problems such as 1406 and 1292.

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 and the test data:

    CREATE DATABASE demo;
    USE demo;
    CREATE TABLE p (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(20) NOT NULL);
  2. Run:

    INSERT INTO p () VALUES ();

You get: Field 'name' doesn't have a default value(11.8.9)

Verified fixes

  1. Add a default to the column (or always supply it)

    ALTER TABLE p ALTER name SET DEFAULT 'unknown';
    INSERT INTO p () VALUES ();
    SELECT name FROM p;

Tested on

StepMySQLMariaDB
5.65.78.08.4910.610.1111.411.8
Omit a NOT NULL column that has no default (strict mode)
repro
≠✓ 1364✓ 1364✓ 1364✓ 1364✓ 1364✓ 1364✓ 1364✓ 1364
Without strict mode an implicit default ('' for strings) is used with warning 1364
version check
⚠ 1364⚠ 3090,1364⚠ 1364⚠ 1364⚠ 1364⚠ 1364⚠ 1364⚠ 1364⚠ 1364
Add a default to the column (or always supply it)
fix
✓✓✓✓✓✓✓✓✓
Omit a NOT NULL column that has no default (strict mode) repro
MySQL 5.6≠5.7✓ 13648.0✓ 13648.4✓ 13649✓ 1364
MariaDB 10.6✓ 136410.11✓ 136411.4✓ 136411.8✓ 1364
Without strict mode an implicit default ('' for strings) is used with warning 1364 version check
MySQL 5.6⚠ 13645.7⚠ 3090,13648.0⚠ 13648.4⚠ 13649⚠ 1364
MariaDB 10.6⚠ 136410.11⚠ 136411.4⚠ 136411.8⚠ 1364
Add a default to the column (or always supply it) 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 (3)
  • Omit a NOT NULL column that has no default (strict mode) (MySQL 5.6): expected error 1364 did not occur
  • Without strict mode an implicit default ('' for strings) is used with warning 1364 (MySQL 5.6, MySQL 8.0, MySQL 8.4, MySQL 9, MariaDB 10.6, MariaDB 10.11, MariaDB 11.4, MariaDB 11.8): warning 1364: Field 'name' doesn't have a default value
  • Without strict mode an implicit default ('' for strings) is used with warning 1364 (MySQL 5.7): warning 3090: Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.; warning 1364: Field 'name' doesn't have a default value

Related errors

  • 1048 ER_BAD_NULL_ERRORexplained
  • 1406 ER_DATA_TOO_LONGexplained