1048: Column 'x' cannot be null
MySQLWhat does it mean?
An attempt was made to insert NULL into a column defined NOT NULL, or to set that column to NULL. A mandatory field cannot be left empty.
Why does it happen?
No value given for a mandatory column in the INSERT; an UPDATE setting the column to NULL; no DEFAULT for the column; an empty value coming from the application/a subquery; strict SQL mode not silently filling the empty value.
How to fix it
Provide a valid value for the mandatory column. Define a sensible default for the column: ALTER TABLE my_table MODIFY my_column INT NOT NULL DEFAULT 0; If the rule is unnecessary, allow NULL: ALTER TABLE my_table MODIFY my_column INT NULL; Validate empty values in the application before sending them.