简体   繁体   English

MySQL:错误 1217 (23000):无法删除或更新父行:外键约束失败 - 但仅适用于 1 个 sql 文件

[英]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:想法/问题:

  1. I tried to edit php.ini file to increase memory limit, max file upload size but there is no effect on PHPMyAdmin interface我试图编辑 php.ini 文件以增加内存限制,最大文件上传大小但对 PHPMyAdmin 界面没有影响
  2. Can I find only one table in sql file and upload the records to the table in my MYSQL database?我可以在 sql 文件中只找到一张表并将记录上传到我的 MYSQL 数据库中的表吗?

在我打开完整的 sql 文件 i Notepad++ 后,该表已更新,仅发现在该特定表中插入值的行,将其保存为新的 sql 文件,然后使用“源”命令。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 #1217 - 无法删除或更新父行:PHPMyAdmin中的外键约束失败 - #1217 - Cannot delete or update a parent row: a foreign key constraint fails in PHPMyAdmin Laravel SQLSTATE[23000] 无法删除或更新父行:外键约束失败 - Laravel SQLSTATE[23000] Cannot delete or update a parent row: a foreign key constraint fails mysql错误错误SQLSTATE [23000]:完整性约束违规:1452无法添加或更新子行:外键约束失败? - mysql error error SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails? SQL错误:SQLSTATE [23000]:完整性约束违规:1452无法添加或更新子行:外键约束失败 - SQL error : SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails Laravel 无法删除或更新父行:外键约束失败 - Laravel Cannot delete or update a parent row: a foreign key constraint fails 无法删除或更新父行,外键约束失败 - Cannot delete or update a parent row, a foreign key constraint fails 此错误是什么SQLSTATE [23000]:违反完整性约束:1452无法添加或更新子行:外键约束失败 - what is this error SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails SQLSTATE [23000]:完整性约束违规:1452无法添加或更新子行:外键约束失败 - SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails Laravel:SQLSTATE [23000]:违反完整性约束:1452无法添加或更新子行:外键约束失败 - Laravel: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails SQLSTATE [23000]:违反完整性约束:1452无法添加或更新子行:Laravel 5中的外键约束失败 - SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails in Laravel 5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM