Home > Database > Mysql Tutorial > body text

Solve and analyze the Incorrect datetime value error problem

藏色散人
Release: 2022-01-12 15:18:11
forward
15325 people have browsed it

This article will introduce how to solve the error problem of Incorrect datetime value: '0000-00-00 00:00:00'. I hope it will be helpful to everyone.

Cause of occurrence:

This error occurs in mysql 5.7 version and above. Problems that will occur:

The default sql configuration of mysql 5.7 version is :sql_mode="ONLY_FULL_GROUP_BY", this configuration strictly implements the "SQL92 standard".​​​

When many people upgrade from 5.6 to 5.7, for the sake of syntax compatibility, most of them will choose to adjust sql_mode to keep it consistent with 5.6, in order to be as compatible with the program as possible.

sql level

When sql is executed, this reason occurs: It's called target list, which is the field that follows select. There is also a place called group by column, which is the field that is followed by

group by. Since the ONLY_FULL_GROUP_BY setting is turned on, if a field does not appear in the target list

and the group by field at the same time, or is the value of an aggregate function, then this SQL query is considered illegal by MySQL and will Report an error.

Solution

Modify the mysql.ini fileAdd under the [mysqld] configuration

sql-mode="STRICT_ALL_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER"
Copy after login

Restart mysql

【Related recommendations:

mysql video tutorial

The above is the detailed content of Solve and analyze the Incorrect datetime value error problem. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:learnku.com
Statement of this Website
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 [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!