Addressing MySQL Error 1364: Understanding and Resolving Field Default Values
When utilizing MySQL, encountering error 1364, indicating a field lacks a default value, can be frustrating. This article aims to address this issue, explaining its cause and providing a solution without altering the affected field or removing the existing trigger.
Error Explanation:
This error arises due to MySQL's STRICT_TRANS_TABLES SQL mode, which enforces strict data validation rules during transactions. When an INSERT statement attempts to insert a value into a field without a defined default, such as the CREATED_BY field in the provided example, MySQL throws this error.
Solution:
To resolve this issue, it is necessary to deactivate the STRICT_TRANS_TABLES mode. This mode can be found in the MySQL configuration file, typically located at %PROGRAMDATA%MySQLMySQL Server 5.6my.ini. By editing this file, users can remove the STRICT_TRANS_TABLES setting and restart MySQL. Upon restarting, the error should no longer occur.
Additional Resources:
For further assistance, refer to the following resources:
The above is the detailed content of How to Fix MySQL Error 1364 Without Changing Field Defaults?. For more information, please follow other related articles on the PHP Chinese website!