当前位置:网站首页>导入 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;
边栏推荐
- MySQL26-性能分析工具的使用
- Emotional classification of 1.6 million comments on LSTM based on pytoch
- Isn't there anyone who doesn't know how to write mine sweeping games in C language
- February 13, 2022 - Maximum subarray and
- MySQL combat optimization expert 07 production experience: how to conduct 360 degree dead angle pressure test on the database in the production environment?
- Moteur de stockage mysql23
- Opencv uses freetype to display Chinese
- [leectode 2022.2.13] maximum number of "balloons"
- [after reading the series] how to realize app automation without programming (automatically start Kwai APP)
- Mysql34 other database logs
猜你喜欢
MySQL28-数据库的设计规范
MySQL20-MySQL的数据目录
MySQL combat optimization expert 12 what does the memory data structure buffer pool look like?
CSDN问答标签技能树(一) —— 基本框架的构建
ByteTrack: Multi-Object Tracking by Associating Every Detection Box 论文阅读笔记()
Not registered via @EnableConfigurationProperties, marked(@ConfigurationProperties的使用)
Unicode decodeerror: 'UTF-8' codec can't decode byte 0xd0 in position 0 successfully resolved
Const decorated member function problem
Mysql21 user and permission management
UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xd0 in position 0成功解决
随机推荐
Mysql27 - Optimisation des index et des requêtes
Security design verification of API interface: ticket, signature, timestamp
MySQL26-性能分析工具的使用
Mysql21 user and permission management
MySQL22-逻辑架构
Anaconda3 installation CV2
Sed text processing
[after reading the series] how to realize app automation without programming (automatically start Kwai APP)
用于实时端到端文本识别的自适应Bezier曲线网络
百度百科数据爬取及内容分类识别
MySQL32-锁
API learning of OpenGL (2005) gl_ MAX_ TEXTURE_ UNITS GL_ MAX_ TEXTURE_ IMAGE_ UNITS_ ARB
MySQL flush operation
[paper reading notes] - cryptographic analysis of short RSA secret exponents
Case identification based on pytoch pulmonary infection (using RESNET network structure)
February 13, 2022-2-climbing stairs
MySQL combat optimization expert 06 production experience: how does the production environment database of Internet companies conduct performance testing?
MySQL33-多版本并发控制
Adaptive Bezier curve network for real-time end-to-end text recognition
Time complexity (see which sentence is executed the most times)