- Error number
- 1364
- SQLSTATE
HY000- Symbol
ER_NO_DEFAULT_FOR_FIELD- Product
- MySQL Server
- Versions
- MySQL 5.7, 8.0 and 8.4 (an error in strict mode, a warning without it)
- Category
- Data Values & Strict Mode
- Last reviewed
- 24 October 2026
On this page
What it means
Error 1364 means an INSERT left out a NOT NULL column that has no DEFAULT, so under strict mode MySQL had no value to store and rejected the row.
When an INSERT does not list a column, MySQL fills it from the column's DEFAULT. A column declared NOT NULL without a DEFAULT clause has nothing to fall back on, so in strict mode (part of MySQL 8.0's default sql_mode) the statement fails with 1364 and names the first such column. The same happens with INSERT ... VALUES () and with the DEFAULT keyword on a column that has no default. An AUTO_INCREMENT column never raises it, but a primary key without AUTO_INCREMENT does.
Without strict mode, MySQL only warns and stores the type's implicit default (an empty string, 0 or a zero date), which is why this error often appears for the first time after moving an application to a server with the default settings. Sending NULL explicitly is a different error, 1048. Inserting through a view that leaves out such a column gives error 1423 instead.
Common causes
- The INSERT lists only some columns and one of the omitted columns is NOT NULL with no DEFAULT.
- A new NOT NULL column was added to the table, but older code or an import still inserts the previous column list.
- The primary key is not AUTO_INCREMENT, so it must be supplied, but the application expects the database to generate it.
- A TEXT, BLOB or JSON column is NOT NULL, and before MySQL 8.0.13 such columns could not have a default at all.
- The application was written against a server without strict mode, where the omission produced only a warning.
Diagnose it
Read-only These statements only read metadata (information_schema, performance_schema and SHOW statements) or your own data. They do not change data, privileges or configuration, so they are safe to run first.
List the columns every INSERT must supply
SELECT column_name, column_type
FROM information_schema.columns
WHERE table_schema = DATABASE()
AND table_name = 'users'
AND is_nullable = 'NO'
AND column_default IS NULL
AND extra NOT LIKE '%auto_increment%'
ORDER BY ordinal_position; Each column returned has no default and does not accept NULL, so every INSERT must give it a value.
See the full definition, including defaults and triggers
SHOW CREATE TABLE users;
SHOW TRIGGERS LIKE 'users'; The DEFAULT clause of each column. A BEFORE INSERT trigger that sets the column also prevents the error (on MySQL 8.0.46 the NOT NULL check ran after the trigger).
Compare the sql_mode on the two servers
Run this on the server that errors and on the one that does not.
SELECT @@SESSION.sql_mode, @@GLOBAL.sql_mode; The server that accepts the INSERT is usually missing STRICT_TRANS_TABLES. Its rows contain empty strings or zeros where real values were expected; check them.
How to fix it
Each fix is labelled with what it changes. Try read-only checks and the least invasive fix first, and test changes outside production.
Include the column in the INSERT
Changes dataIf the value is required (a password hash, an owner, a status), the INSERT must supply it. List columns explicitly so new columns are noticed when the table changes.
INSERT INTO users (username, password_hash)
VALUES ('sara', 'hash-from-your-password-library');
Give the column a sensible DEFAULT
Changes schemaIf there is a value that is correct for most new rows (a status of 'active', a timestamp, a zero counter), declare it. TEXT, BLOB and JSON columns need an expression default in brackets, allowed from MySQL 8.0.13.
Caution: Choose a default that is true for the business, not just one that makes the INSERT pass. On large tables, MODIFY may rebuild the table; run it in a maintenance window.
ALTER TABLE users MODIFY status VARCHAR(20) NOT NULL DEFAULT 'active';
ALTER TABLE notes MODIFY body TEXT NOT NULL DEFAULT ('');
Let MySQL generate the primary key
Changes schemaIf the application expects ids to be generated, the key needs AUTO_INCREMENT. Then omit it from the INSERT and read the new value with LAST_INSERT_ID().
Caution: Changing the key column rebuilds the table. If other tables reference it through foreign keys, test the change on a copy first and run it in a maintenance window.
ALTER TABLE tags MODIFY id INT NOT NULL AUTO_INCREMENT;
Make the column nullable if the value is genuinely optional
Changes schemaIf "no value" is valid (a phone number, a note), allow NULL; NULL then becomes the default.
ALTER TABLE users MODIFY phone VARCHAR(30) NULL;
Examples
Leaving out a required column
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL,
password_hash VARCHAR(255) NOT NULL
);
INSERT INTO users (username) VALUES ('sara');
ERROR 1364 (HY000): Field 'password_hash' doesn't have a default value
Reproduced on MySQL 8.0.46, 24 October 2026.
A primary key without AUTO_INCREMENT
CREATE TABLE tags (
id INT PRIMARY KEY, -- not AUTO_INCREMENT
label VARCHAR(30)
);
INSERT INTO tags (label) VALUES ('sql');
ERROR 1364 (HY000): Field 'id' doesn't have a default value
Reproduced on MySQL 8.0.46, 24 October 2026.
A NOT NULL TEXT column with no default
CREATE TABLE notes (
id INT PRIMARY KEY,
body TEXT NOT NULL
);
INSERT INTO notes (id) VALUES (1);
ERROR 1364 (HY000): Field 'body' doesn't have a default value
Reproduced on MySQL 8.0.46, 24 October 2026.
Using the DEFAULT keyword on a column that has no default
CREATE TABLE orders (
id INT AUTO_INCREMENT PRIMARY KEY,
customer_id INT NOT NULL,
order_date DATE NOT NULL
);
INSERT INTO orders (customer_id, order_date) VALUES (1, DEFAULT);
ERROR 1364 (HY000): Field 'order_date' doesn't have a default value
Reproduced on MySQL 8.0.46, 24 October 2026.
How to prevent it
Always name the columns in an INSERT, and when you add a NOT NULL column to an existing table, either give it a DEFAULT or update every code path that inserts into the table in the same release. Use AUTO_INCREMENT for surrogate keys you expect the database to generate.
Run development and test servers with the same sql_mode as production (strict mode, the MySQL 8.0 default) so 1364 shows up before release. Do not switch strict mode off to make it go away: the rows are then stored with empty strings or zeros and no error, and the missing data is only found much later.
Common questions
How do I fix "Field doesn't have a default value" in MySQL?
Include the named column in the INSERT, or, if a standard value makes sense for new rows, give the column a DEFAULT. If the column is the primary key and you expect generated ids, make it AUTO_INCREMENT.
Why did error 1364 start after a server upgrade or move?
The new server runs in strict mode (STRICT_TRANS_TABLES is in MySQL 8.0's default sql_mode). The old one probably did not, so the same INSERT only produced a warning and stored an empty string or 0.
Should I remove STRICT_TRANS_TABLES from sql_mode to fix 1364?
No. That hides this and many other data errors (out-of-range numbers, invalid dates, truncated text) and stores wrong values silently. Fix the INSERT or the table definition instead.
What is the difference between error 1364 and error 1048?
1364 means a NOT NULL column without a default was left out of the INSERT. 1048 means NULL was sent explicitly for a NOT NULL column.
Learn more on CodeWithSQL
Official documentation
Last technically reviewed 24 October 2026; examples and diagnostics run on MySQL 8.0.46. Message templates checked against the server's error catalogue (perror) for that version.