当前位置:网站首页>导入 SQL 时出现 Invalid default value for ‘create_time‘ 报错解决方法
导入 SQL 时出现 Invalid default value for ‘create_time‘ 报错解决方法
2022-07-06 09:12:00 【程序员柒七】
方案一
重装 MySQL 数据库,版本选择 5.7 或者 5.7 以上版本,这个方案有些粗暴,不喜欢粗暴的朋友可以继续往下看。
方案二
这个错误的主要原因,是因为给了时间字段的列默认值一个 CURRENT_TIMESTAMP 默认值,而这个默认值在低版本的 MySQL 中是不支持的,因此就出现了题目中的这个报错,所以呢,把每个时间字段的默认值修改一下即可,比如:
DROP TABLE IF EXISTS `tb_config`;
CREATE TABLE `tb_config` (
`config_name` varchar(100) NOT NULL DEFAULT '' COMMENT '配置项的名称',
`config_value` varchar(200) NOT NULL DEFAULT '' COMMENT '配置项的值',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
PRIMARY KEY (`config_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
改为
DROP TABLE IF EXISTS `tb_config`;
CREATE TABLE `tb_config` (
`config_name` varchar(100) NOT NULL DEFAULT '' COMMENT '配置项的名称',
`config_value` varchar(200) NOT NULL DEFAULT '' COMMENT '配置项的值',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (`config_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
边栏推荐
- Mysql25 index creation and design principles
- MySQL20-MySQL的数据目录
- MySQL19-Linux下MySQL的安装与使用
- 实现微信公众号H5消息推送的超级详细步骤
- Mysql21 - gestion des utilisateurs et des droits
- 该不会还有人不懂用C语言写扫雷游戏吧
- Pytorch RNN actual combat case_ MNIST handwriting font recognition
- [untitled]
- UEditor国际化配置,支持中英文切换
- ZABBIX introduction and installation
猜你喜欢
Mysql32 lock
Pytorch RNN actual combat case_ MNIST handwriting font recognition
[reading notes] rewards efficient and privacy preserving federated deep learning
MySQL real battle optimization expert 11 starts with the addition, deletion and modification of data. Review the status of buffer pool in the database
解决在window中远程连接Linux下的MySQL
Super detailed steps to implement Wechat public number H5 Message push
CSDN问答模块标题推荐任务(一) —— 基本框架的搭建
用于实时端到端文本识别的自适应Bezier曲线网络
MySQL31-MySQL事务日志
CSDN问答标签技能树(五) —— 云原生技能树
随机推荐
ByteTrack: Multi-Object Tracking by Associating Every Detection Box 论文阅读笔记()
Texttext data enhancement method data argument
Ueeditor internationalization configuration, supporting Chinese and English switching
Mysql26 use of performance analysis tools
MNIST implementation using pytoch in jupyter notebook
February 13, 2022 - Maximum subarray and
[after reading the series] how to realize app automation without programming (automatically start Kwai APP)
Record the first JDBC
MySQL31-MySQL事务日志
Google login prompt error code 12501
Use JUnit unit test & transaction usage
Introduction tutorial of typescript (dark horse programmer of station B)
Not registered via @enableconfigurationproperties, marked (@configurationproperties use)
Mysql21 user and permission management
[unity] simulate jelly effect (with collision) -- tutorial on using jellysprites plug-in
MySQL18-MySQL8其它新特性
Mysql21 - gestion des utilisateurs et des droits
Mysql25 index creation and design principles
MySQL21-用户与权限管理
MySQL26-性能分析工具的使用