ighack
(Ighack)
2020 年7 月 20 日 02:36
1
为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【TiDB 版本】:tidb 4.0-rc
【问题描述】:Invalid default value for ‘Created_Time’,我把mysql的dmp通过lightning恢复到tidb里面去。但我有很多时间字段如
mdb.fd_vehicle-schema.sql: Created_Time
datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ‘申请时间’,
在恢复的时候报Invalid default value for ‘Created_Time’
来了老弟
2020 年7 月 20 日 03:07
2
你好,
4.x 希望可以通过 tiup upgrade 升级到 v4.0.2,关于当前问题应该是 sql_mode 设置的原因,可以使用以下命令查看 sql_mode SHOW GLOBAL VARIABLES LIKE 'sql_mode';
并通过 set @@global.sql_mode =’’; 设置空 sql_mode 来解决此问题
ighack
(Ighack)
2020 年7 月 20 日 06:18
3
我已经set @@global.sql_mode =’’;
但还是提示同样的错误
来了老弟
2020 年7 月 20 日 06:19
4
可否返回下完整的 sql 和 报错内容,
上传下报错时,tidb.log 看是否存在详细信息。
ighack
(Ighack)
2020 年7 月 20 日 06:21
5
./bin/tidb-lightning -config tidb-lightning.toml
Error: restore table schema mdb failed: create table failed: Error 1067: Invalid default value for ‘Created_Time’
[2020/07/20 14:17:38.532 +08:00] [ERROR] [tidb.go:124] ["create tables failed"] [db=mdb] [takeTime=22.262854822s] [error="create table failed: Error 1067: Invalid default value for 'Created_Time'"]
[2020/07/20 14:17:38.532 +08:00] [ERROR] [restore.go:308] ["restore table schema failed"] [db=mdb] [takeTime=22.541720155s] [error="create table failed: Error 1067: Invalid default value for 'Created_Time'"]
[2020/07/20 14:17:38.533 +08:00] [ERROR] [restore.go:277] ["run failed"] [step=1] [error="restore table schema mdb failed: create table failed: Error 1067: Invalid default value for 'Created_Time'"]
[2020/07/20 14:17:38.533 +08:00] [ERROR] [restore.go:283] ["the whole procedure failed"] [takeTime=22.552301634s] [error="restore table schema mdb failed: create table failed: Error 1067: Invalid default value for 'Created_Time'"]
[2020/07/20 14:17:38.533 +08:00] [ERROR] [main.go:75] ["tidb lightning encountered error"] [error="restore table schema mdb failed: create table failed: Error 1067: Invalid default value for 'Created_Time'"] [errorVerbose="Error 1067: Invalid default value for 'Created_Time'\
github.com/pingcap/errors.AddStack\
\t/home/jenkins/agent/workspace/release_tidb_4.0/go/pkg/mod/github.com/pingcap/errors@v0.11.5-0.20190809092503-95897b64e011/errors.go:174\
github.com/pingcap/errors.Trace\
\t/home/jenkins/agent/workspace/release_tidb_4.0/go/pkg/mod/github.com/pingcap/errors@v0.11.5-0.20190809092503-95897b64e011/juju_adaptor.go:15\
github.com/pingcap/tidb-lightning/lightning/common.SQLWithRetry.Exec.func1\
\t/home/jenkins/agent/workspace/release_tidb_4.0/go/src/github.com/pingcap/tidb-lightning/lightning/common/util.go:172\
github.com/pingcap/tidb-lightning/lightning/common.SQLWithRetry.perform\
\t/home/jenkins/agent/workspace/release_tidb_4.0/go/src/github.com/pingcap/tidb-lightning/lightning/common/util.go:110\
github.com/pingcap/tidb-lightning/lightning/common.SQLWithRetry.Exec\
\t/home/jenkins/agent/workspace/release_tidb_4.0/go/src/github.com/pingcap/tidb-lightning/lightning/common/util.go:170\
github.com/pingcap/tidb-lightning/lightning/restore.(*TiDBManager).InitSchema\
\t/home/jenkins/agent/workspace/release_tidb_4.0/go/src/github.com/pingcap/tidb-lightning/lightning/restore/tidb.go:119\
github.com/pingcap/tidb-lightning/lightning/restore.(*RestoreController).restoreSchema\
\t/home/jenkins/agent/workspace/release_tidb_4.0/go/src/github.com/pingcap/tidb-lightning/lightning/restore/restore.go:306\
github.com/pingcap/tidb-lightning/lightning/restore.(*RestoreController).Run\
\t/home/jenkins/agent/workspace/release_tidb_4.0/go/src/github.com/pingcap/tidb-lightning/lightning/restore/restore.go:267\
github.com/pingcap/tidb-lightning/lightning.(*Lightning).run\
\t/home/jenkins/agent/workspace/release_tidb_4.0/go/src/github.com/pingcap/tidb-lightning/lightning/lightning.go:221\
github.com/pingcap/tidb-lightning/lightning.(*Lightning).RunOnce\
\t/home/jenkins/agent/workspace/release_tidb_4.0/go/src/github.com/pingcap/tidb-lightning/lightning/lightning.go:146\
main.main\
\t/home/jenkins/agent/workspace/release_tidb_4.0/go/src/github.com/pingcap/tidb-lightning/cmd/tidb-lightning/main.go:72\
runtime.main\
\t/usr/local/go/src/runtime/proc.go:203\
runtime.goexit\
\t/usr/local/go/src/runtime/asm_amd64.s:1357\
create table failed\
restore table schema mdb failed"]
来了老弟
2020 年7 月 20 日 06:26
7
tidb 中执行下 SHOW GLOBAL VARIABLES LIKE ‘sql_mode’;
在看下 [2020/07/20 14:17:38.532 +08:00] 对应时间的 tidb.log 。
ighack
(Ighack)
2020 年7 月 20 日 06:33
9
Created_Time
timestamp NOT NULL DEFAULT ‘0000-00-00 00:00:00’ ON UPDATE CURRENT_TIMESTAMP
看是不是这个东西的问题
glorvs
(gaolei-PingCAP)
2020 年7 月 20 日 06:45
11
datetime 类型取值范围:1000-01-01 00:00:00 到 9999-12-31 23:59:59 所以不能设置为 0000-00-00 这样