Home >Database >Mysql Tutorial >How to solve the mysql error '#1067 invalid default value'
This article will introduce to you how to solve the mysql error "#1067 invalid default value". It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
Reminder: The information described in this article may have changed, please use it with caution.
Wordpress has deleted a lot of comments, resulting in a large gap in the comment ID. If you want to continue, use the following command to modify the auto-increment ID and count again:
The result is an error, prompt:
#1067 – Invalid default value for comment_date
I remember that there was no problem using this command before. After searching online, I found that it was a problem with mysql. I used to use mysql5.6, but I just upgraded it to 5.7 not long ago. The method online worked.
Directly follow the online tutorial to modify the mysql configuration file my.cnf, edit my.cnf
Add the following content under [mysqld]:
After saving, restart mysql, Execute the command to modify the auto-increment ID again, and everything will be normal.
There is also a temporary method mentioned on the Internet:
The reason for this problem is that the default value of comment_date is 0000-00-00 00:00:00. Check sql_mode, which contains "NO_ZERO_IN_DATE, NO_ZERO_DATE", the time limit of these two parameters cannot be 0, so an error will be reported!
Related recommendations: "mysql tutorial"
The above is the detailed content of How to solve the mysql error '#1067 invalid default value'. For more information, please follow other related articles on the PHP Chinese website!