Home >Database >Mysql Tutorial >Why Does MySQL 5.7.11 Return 'Incorrect date value: '0000-00-00'' and How Can I Fix It?

Why Does MySQL 5.7.11 Return 'Incorrect date value: '0000-00-00'' and How Can I Fix It?

DDD
DDDOriginal
2024-12-23 09:38:14312browse

Why Does MySQL 5.7.11 Return

Issue with Incorrect Date Value: '0000-00-00'

In MySQL version 5.7.11, users have encountered an issue while inserting values into a table with a date type column having a default value of '0000-00-00' using phpMyAdmin. The error reported is "Incorrect date value: '0000-00-00'".

Understanding the Root Cause

Upon investigation, it was discovered that this error is caused by the SQL mode settings, specifically the inclusion of strict mode. In MySQL 5.7, stricter validation is enforced by default, including the rejection of '0000-00-00' as a valid date.

Resolving the Issue

To resolve this issue, it is necessary to disable strict mode. This can be achieved by executing the following query:

SET GLOBAL sql_mode = '';

By running this query, strict mode will be temporarily disabled, allowing for the insertion of '0000-00-00' as a valid date without encountering the error.

Additional Information

For further comprehension of SQL mode settings, refer to the MySQL documentation. This issue has been reported and acknowledged by the MySQL team as a known behavior change introduced in version 5.7. Disabling strict mode is a common solution to resolve this particular problem.

The above is the detailed content of Why Does MySQL 5.7.11 Return 'Incorrect date value: '0000-00-00'' and How Can I Fix It?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn