• MySQL 5.7 Invalid default value for 'CREATE_TIME'报错的解决方法


    出处:http://blog.itpub.net/15498/viewspace-2136006/

    由于数据库的升级,今天在执行从MySQL 5.6导出来的SQL文件时报错:

    mysql> source cms_user.sql
    Query OK, 0 rows affected (0.00 sec)

    Query OK, 0 rows affected, 1 warning (0.04 sec)

    ERROR 1067 (42000): Invalid default value for 'CREATE_TIME'
    ERROR 1146 (42S02): Table 'ixinnuo_zxpt.cms_user' doesn't exist


    因为MySQL 5.6以后timestamp设定默认值规则改变,不能为”0000 00-00 00:00:00”

    解决方法:
    查看sql_mode:
    mysql> show session variables like '%sql_mode%';
    +---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
    | Variable_name | Value                                                                                                                                     |
    +---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
    | sql_mode      | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
    +---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
    1 row in set (0.01 sec)

    修改sql_mode,去掉NO_ZERO_IN_DATE,NO_ZERO_DATE:
    mysql> set sql_mode="ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION";
    Query OK, 0 rows affected, 1 warning (0.00 sec)

    重新执行,成功:
    mysql> source cms_user.sql
    Query OK, 0 rows affected (0.00 sec)

    Query OK, 0 rows affected, 1 warning (0.03 sec)

    Query OK, 0 rows affected (0.55 sec)

    Query OK, 1 row affected (0.07 sec)

  • 相关阅读:
    js 提示框的实现---组件开发之(一)
    js 原型链
    js 哈希路由原理实现
    js 弹窗的实现
    js 滑动门的实现
    Delphi IDFtp用法,包含断点续传
    memortstream Base64编码和filestream base64编码不同
    Delphi另一个多线程函数:BeginThread用法
    delphi 讲的比较详细的多线程(推荐)
    多线程简单实用
  • 原文地址:https://www.cnblogs.com/jiliunyongjin/p/7569893.html
Copyright © 2020-2023  润新知