当前位置:网站首页>Invalid default value for 'create appears when importing SQL_ Time 'error reporting solution

Invalid default value for 'create appears when importing SQL_ Time 'error reporting solution

2022-07-06 10:45:00 Programmer seven seven

Scheme 1

reinstall MySQL database , Version selection 5.7 perhaps 5.7 Above version , This plan is a little rough , Friends who don't like rudeness can keep looking down .

Option two

The main reason for this mistake , The reason is that the default value of the time field column is CURRENT_TIMESTAMP The default value is , And this default is in the lower version of MySQL China does not support , So there is the wrong report in the title , So , Change the default value of each time field , such as :

DROP TABLE IF EXISTS `tb_config`;

CREATE TABLE `tb_config` (
  `config_name` varchar(100) NOT NULL DEFAULT '' COMMENT ' Name of configuration item ',
  `config_value` varchar(200) NOT NULL DEFAULT '' COMMENT ' The value of the configuration item ',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ' Creation time ',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ' Modification time ',
  PRIMARY KEY (`config_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Change it to

DROP TABLE IF EXISTS `tb_config`;

CREATE TABLE `tb_config` (
  `config_name` varchar(100) NOT NULL DEFAULT '' COMMENT ' Name of configuration item ',
  `config_value` varchar(200) NOT NULL DEFAULT '' COMMENT ' The value of the configuration item ',
  `create_time` datetime DEFAULT NULL COMMENT ' Creation time ',
  `update_time` datetime DEFAULT NULL COMMENT ' Modification time ',
  PRIMARY KEY (`config_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

 

原网站

版权声明
本文为[Programmer seven seven]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060911410935.html