Monday, June 18, 2007

MySQL error: Field doesn't have a default value

When inserting a new record with varchar or text field that is required and has no default value. This error will display for example:

error : Field 'description' doesn't have a default value

The possible reason is that sql-mode in my.ini is set to STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION.

Change the value to
sql-mode = ""

Update 2011/4/25:
Add Default value "" if possible to avoid changing mysql setting.


Ryan said...

I can't find a my.ini file to add this to, either on my Linux server or my local windows development machine. Any suggestions?

choybi said...

Try my.cnf