Invalid default value for 'updated_at'

  • 最近在Mysql的query语句中出现了这样的错误

Invalid default value for ‘updated_at’

解决方法如下:

  • 执行SQL语句:show variables like 'sql_mode';

    如何发现query结果中有如下两个modes:NO_ZERO_IN_DATE和NO_ZERO_DATE

    则移除这两个modes:set set session sql_mode='这里面填查询结果除去上面两个modes的值'

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

    SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
    SET time_zone = "+00:00";
    
  • before you run any query put this query in the first line:

    SET sql_mode = '';

你可能感兴趣的:(数据库)