当前位置:网站首页>导入 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;
边栏推荐
- 数据库中间件_Mycat总结
- How to build an interface automation testing framework?
- Global and Chinese markets for aprotic solvents 2022-2028: Research Report on technology, participants, trends, market size and share
- ZABBIX introduction and installation
- PyTorch RNN 实战案例_MNIST手写字体识别
- Mysql27 index optimization and query optimization
- Solve the problem of remote connection to MySQL under Linux in Windows
- Record the first JDBC
- CSDN问答标签技能树(一) —— 基本框架的构建
- 使用OVF Tool工具从Esxi 6.7中导出虚拟机
猜你喜欢

Use JUnit unit test & transaction usage

Const decorated member function problem

MySQL combat optimization expert 04 uses the execution process of update statements in the InnoDB storage engine to talk about what binlog is?

Not registered via @EnableConfigurationProperties, marked(@ConfigurationProperties的使用)

MySQL33-多版本并发控制

使用OVF Tool工具从Esxi 6.7中导出虚拟机

Mysql26 use of performance analysis tools
![[C language] deeply analyze the underlying principle of data storage](/img/d6/1c0cd38c75da0d0cc1df7f36938cfb.png)
[C language] deeply analyze the underlying principle of data storage
![[after reading the series] how to realize app automation without programming (automatically start Kwai APP)](/img/e1/bad9cfa70d3c533cfaddeee40b96f1.jpg)
[after reading the series] how to realize app automation without programming (automatically start Kwai APP)

MySQL36-数据库备份与恢复
随机推荐
MySQL learning diary (II)
Windchill configure remote Oracle database connection
Mysql33 multi version concurrency control
Adaptive Bezier curve network for real-time end-to-end text recognition
PyTorch RNN 实战案例_MNIST手写字体识别
MySQL36-数据库备份与恢复
MySQL的存储引擎
Opencv uses freetype to display Chinese
评估方法的优缺点
C语言标准的发展
MySQL flush operation
[paper reading notes] - cryptographic analysis of short RSA secret exponents
Mysql23 storage engine
Introduction tutorial of typescript (dark horse programmer of station B)
How to build an interface automation testing framework?
CSDN博文摘要(一) —— 一个简单的初版实现
Pytoch LSTM implementation process (visual version)
高并发系统的限流方案研究,其实限流实现也不复杂
MySQL25-索引的创建与设计原则
UEditor国际化配置,支持中英文切换