As indicated by the warning, to turn off the nonstandard behaviors, enable the new explicit_defaults_for_timestamp system variable at server startup. With this variable enabled, the server handles TIMESTAMP as follows instead:
所显示的警告,关闭非标准的行为,使新的explicit_defaults_for_timestamp系统变量在服务器启动时启用了这个变量,服务器处理时间戳,如下所示:
TIMESTAMP columns not explicitly declared as NOT NULL permit NULL values. Setting such a column to NULL sets it to NULL, not the current timestamp.
时间戳列没有明确声明为not NULL允许NULL值。设置这样的列为NULL将它设置为NULL,并不是当前的时间戳。
No TIMESTAMP column is assigned the DEFAULT CURRENT_TIMESTAMP or ON UPDATE CURRENT_TIMESTAMP attributes automatically. Those attributes must be explicitly specified.
不会自动指定默认TIMESTAMP列 为CURRENT_TIMESTAMP或更新CURRENT_TIMESTAMP属性。这些属性必须显式地指定。
TIMESTAMP columns declared as NOT NULL and without an explicit DEFAULT clause are treated as having no default value. For inserted rows that specify no explicit value for such a column, the result depends on the SQL mode. If strict SQL mode is enabled, an error occurs. If strict SQL mode is not enabled, the column is assigned the implicit default of '0000-00-00 00:00:00' and a warning occurs. This is similar to how MySQL treats other temporal types such as DATETIME.
TIMESTAMP列声明为NOT NULL,没有一个明确的 DEFAULT 值被视为没有默认值。为插入的行指定没有显式值的列,结果取决于SQL模式。如果启用了SQL模式严格,出现一个错误。如果严格SQL模式未启用,列分配隐含默认值“0000-00-00,”和一个警告的发生。这类似于MySQL如何对待其他时态类型如DATETIME。
修改 my.ini
[mysqld ]
添加 explicit_defaults_for_timestamp=true