查看mysql启动日志
140213 16:24:19 mysqld_safe Starting mysqld daemon with databases from /data/mydata/2014-02-13 16:24:22 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
查阅官方文档:
这是数据库升级过程中,timestamp在5.6以前的数据库中默认not null,如果没有显示声明timestamp的默认值,那么该列用全0的"0000-00-00 00:00:00"作为默认值
在5.6中,时间值是不能为全0格式,添加 参数
添加之后,timestamp列可以设置默认为空,并且不填充0,如果填充了0,如果SQL_MODE为strict sql则会报错
除非显示指定default current_time和on update current_time
在配置文件中加入参数后,创建一张表
root@localhost>create table tim(dd timestamp,id int);Query OK, 0 rows affected (0.03 sec)root@localhost>desc tim -> ;+-------+-----------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+-------+-----------+------+-----+---------+-------+| dd | timestamp | YES | | NULL | || id | int(11) | YES | | NULL | |+-------+-----------+------+-----+---------+-------+
已经默认null了