展示引擎Innodb状态\ G给了我这一点:DROP TABLE IF EXISTS `channel_tags`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `channel_tags` ( `channel_tag_id` bigint(20) NOT NULL AUTO_INCREMENT, `channel_id` bigint(20) NOT NULL, `tag_name` varchar(60) NOT NULL, PRIMARY KEY (`channel_tag_id`), KEY `channel_id_idx` (`channel_id`), KEY `tag_name_idx` (`tag_name`), CONSTRAINT `ct_channel_fk` FOREIGN KEY (`channel_id`) REFERENCES `channel_shard` (`channel_id`), CONSTRAINT `ct_tag_fk` FOREIGN KEY (`tag_name`) REFERENCES `tags` (`tag_name`) ) ENGINE=InnoDB AUTO_INCREMENT=833 DEFAULT CHARSET=utf8mb4; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `tags`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `tags` ( `tag_name` varchar(60) NOT NULL, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, PRIMARY KEY (`tag_name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; /*!40101 SET character_set_client = @saved_cs_client */;
创建表语句的顺序相同。
------------------------
LATEST FOREIGN KEY ERROR
------------------------
2015-12-07 17:20:16 1ac30b000 Error in foreign key constraint of table sde/channel_tags:
FOREIGN KEY (`tag_name`) REFERENCES `tags` (`tag_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4:
Cannot find an index in the referenced table where the
referenced columns appear as the first columns, or column types
in the table and the referenced table do not match for constraint.
Note that the internal storage type of ENUM and SET changed in
tables created with >= InnoDB-4.1.12, and such columns in old tables
cannot be referenced by such columns in new tables.
See http://dev.mysql.com/doc/refman/5.6/en/innodb-foreign-key-constraints.html
for correct foreign key definition.
有人可以让我知道这里发生了什么吗?
我也有这个错误。
我猜想你和我做了相同的事情:将整个DB设置为
UTF8
UTF8MB4
之后。
我不知道如何解决。 但是,有一个解决方法:将所有UTF8MB4
更改为dump sql文件中的UTF8,将其还原为db,然后将特定列更改为这些命令的手动手动:
UTF8MB4
我的转储和DB中没有UTF8MB4 charset,但是遇到了问题。 我解决了它卸下所有桌子并在恢复我的垃圾箱之后。
使用以下内容:如何从命令行中删除所有MySQL表,而无需DROP数据库权限?对于任何人可能会有所帮助的人,我都遇到了同样的问题,因为我使用了
ALTER DATABASE [dbname] CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
ALTER TABLE [tablename] CHANGE [colname] [colname] VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
SET FOREIGN_KEY_CHECKS=0;
ALTER TABLE [tablename] CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
SET FOREIGN_KEY_CHECKS=1;
的选项。 事实证明,此选项会产生一个未设置
--compact
其他问题的解释是,当您执行A
mysqldump
时,转储文件顶部的生成的FOREIGN_KEY_CHECKS=0
节可能不完整。 转储文件通常以
mysqldump
CREATE TABLE
语句之前插入数据。 当某些数据库文件已经存在时,这可能会生成OP提及的错误(即仅恢复一个表)。 为了克服这个问题,您可以做的就是修改生成的
ALTER TABLE
语句,以便它完成,并且不需要任何进一步的语句。
确定我的情况是什么问题,但是
ALTER TABLE
然后CREATE TABLE
随后导入转储文件解决了我的问题。