Home >Database >Mysql Tutorial >Why am I getting the \'Field Doesn\'t Have Default Value\' error in MySQL STRICT Mode?
In a recent migration from MAMP to Apache, MySQL, and PHP, performing INSERT commands suddenly resulted in the following error:
SQLSTATE[HY000]: General error: 1364 Field 'display_name' doesn't have a default value
This issue arose due to a change in MySQL's default behavior. In MySQL version 5.6.13, STRICT mode is often enabled, which enforces stricter rules for data validation. As a result, fields without default values can no longer be left blank during insertion.
To resolve this issue, it is necessary to change the MySQL STRICT mode setting. There are two possible solutions:
Temporary Change: Run the following command in your MySQL console:
SET GLOBAL sql_mode='';
This will temporarily disable STRICT mode for all subsequent queries.
After making either of these changes, restart the MySQL server, and the INSERT commands should execute successfully without the "Field Doesn't Have Default Value" error.
The above is the detailed content of Why am I getting the \'Field Doesn\'t Have Default Value\' error in MySQL STRICT Mode?. For more information, please follow other related articles on the PHP Chinese website!