Invalid default value for ‘updated_at’

Recently, such an error occurred in the query statement of Mysql

 Invalid default value for 'updated_at'

The solution is as follows:

 Execute SQL statement: show variables like 'sql_mode';
 How to find the following two modes in the query result: NO_ZERO_IN_DATE and NO_ZERO_DATE
 Then remove these two modes:set set session sql_mode='Fill in the query results here to remove the values ​​of the above two modes'
 before you run any query put this query in the first line:

before you run any query put this query in the first line:

SET sql_mode = ”;

Leave a Reply

Your email address will not be published. Required fields are marked *

en_USEnglish