当前位置:网站首页>导入 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;
边栏推荐
- [programmers' English growth path] English learning serial one (verb general tense)
- In fact, the implementation of current limiting is not complicated
- MySQL34-其他数据库日志
- MySQL30-事务基础知识
- Baidu Encyclopedia data crawling and content classification and recognition
- MySQL 29 other database tuning strategies
- MySQL combat optimization expert 05 production experience: how to plan the database machine configuration in the real production environment?
- MySQL23-存儲引擎
- MySQL35-主从复制
- 好博客好资料记录链接
猜你喜欢

Just remember Balabala

MySQL 20 MySQL data directory

In fact, the implementation of current limiting is not complicated

Mysql34 other database logs

该不会还有人不懂用C语言写扫雷游戏吧
![[C language] deeply analyze the underlying principle of data storage](/img/d6/1c0cd38c75da0d0cc1df7f36938cfb.png)
[C language] deeply analyze the underlying principle of data storage

MySQL storage engine

CSDN问答模块标题推荐任务(一) —— 基本框架的搭建

How to build an interface automation testing framework?

MySQL transaction log
随机推荐
Global and Chinese market of operational amplifier 2022-2028: Research Report on technology, participants, trends, market size and share
MySQL的存储引擎
Software test engineer development planning route
Use of dataset of pytorch
Anaconda3 安装cv2
Mysql33 multi version concurrency control
[Li Kou 387] the first unique character in the string
MySQL21-用戶與權限管理
Discriminant model: a discriminant model creation framework log linear model
MySQL底层的逻辑架构
@controller,@service,@repository,@component区别
MySQL combat optimization expert 05 production experience: how to plan the database machine configuration in the real production environment?
Adaptive Bezier curve network for real-time end-to-end text recognition
Use JUnit unit test & transaction usage
Isn't there anyone who doesn't know how to write mine sweeping games in C language
MySQL30-事务基础知识
MySQL22-逻辑架构
Not registered via @enableconfigurationproperties, marked (@configurationproperties use)
Database middleware_ MYCAT summary
MySQL combat optimization expert 07 production experience: how to conduct 360 degree dead angle pressure test on the database in the production environment?