MySQL error «Field xxx doesn’t have a default value»

0
(0)

If you get mysql error:

«Field xxx doesn’t have a default value»

This means that when inserting or updating data, the field does not have a default value. To solve the problem you need:

  • find this request and fix it, add the required field;
  • in the table properties specify the default value;

Another solution is turning off mysql mode: “Strict Mode”, i.e. we turn off strict compliance with MySql.

You can turn it off in the my.ini config:
writing instead:

# Set the SQL mode to strict
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

following code:

# Set the SQL mode to strict
sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

Or by running the following query:

SET @@GLOBAL.sql_mode= ''
SET @@SESSION.sql_mode= ''
When strict mode is turned off:
for numeric values, the default will be 0, and
for string - there will be an empty string.

Similar Posts:

1,774

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Scroll to Top