MySQL Incorrect datetime value: '0000-00-00 00:00:00'

后端 未结 19 1025
没有蜡笔的小新
没有蜡笔的小新 2020-11-29 15:51

I\'ve recently taken over an old project that was created 10 years ago. It uses MySQL 5.1.

Among other things, I need to change the default character set from latin1

19条回答
  •  庸人自扰
    2020-11-29 16:38

    This is what I did to solve my problem. I tested in local MySQL 5.7 ubuntu 18.04.

    set global sql_mode="NO_ENGINE_SUBSTITUTION";
    

    Before running this query globally I added a cnf file in /etc/mysql/conf.d directory. The cnf file name is mysql.cnf and codes

    [mysqld]
    sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ALLOW_INVALID_DATES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
    

    Then I restart mysql

    sudo service mysql restart
    

    Hope this can help someone.

提交回复
热议问题