[英]MySQL: ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails - but only for 1 sql file
I'm trying to import data from sql files into local MySQL database.我正在尝试将数据从 sql 文件导入本地 MySQL 数据库。 I'm using WampServer2.5, MySQL 5.6.17.我使用的是 WampServer2.5,MySQL 5.6.17。 I'm importing them using MySQL console as PHPMyAdmin interface was causing some problems.我正在使用 MySQL 控制台导入它们,因为 PHPMyAdmin 界面导致了一些问题。
First two files seem to be uploaded correctly.前两个文件似乎已正确上传。 However, they were much smaller than the third one.然而,它们比第三个小得多。 The steps are always the same:步骤总是一样的:
1. create database xyz;
2. use database xyz;
3. SET FOREIGN_KEY_CHECKS = 0;
4. source path/to/the/xyz.sql
When uploading the third file at some point I get this errors (a couple in a row, then it keeps uploading):在某个时候上传第三个文件时,我收到此错误(连续几个,然后它继续上传):
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: [some number]
Current database: xyz
Then a get a few of those, which is strange as I set that in the beginning (maybe there is some reset of this setting when connection is lost?):然后获取其中的一些,这很奇怪,因为我在开始时设置了它(当连接丢失时,可能会重置此设置?):
ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails
The result is I have all the tables uploaded, but some of them have no data - mostly because they are referencing user table from that third database, which has no records.结果是我上传了所有表,但其中一些没有数据 - 主要是因为它们引用了没有记录的第三个数据库中的用户表。
Ideas / questions:想法/问题:
在我打开完整的 sql 文件 i Notepad++ 后,该表已更新,仅发现在该特定表中插入值的行,将其保存为新的 sql 文件,然后使用“源”命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.