mysql - 无法添加或更新子行: a foreign key constraint fails in magetno

标签 mysql magento

我正在尝试使用 phpmyadmin 导入 sql 转储。 我收到以下错误

catalog_compare_item的约束

ALTER TABLE `catalog_compare_item`
ADD CONSTRAINT `FK_MAG_CATALOG_COMPARE_ITEM_STORE_ID_MAG_CORE_STORE_STORE_ID` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`) ON DELETE SET NULL ON UPDATE CASCADE,
ADD CONSTRAINT `FK_MAG_CAT_CMP_ITEM_CSTR_ID_MAG_CSTR_ENTT_ENTT_ID` FOREIGN KEY (`customer_id`) REFERENCES `customer_entity` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `FK_MAG_CAT_CMP_ITEM_PRD_ID_MAG_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`product_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE;

#1452 - Cannot add or update a child row: a foreign key constraint fails (`checktest`.`#sql-c74_23`, CONSTRAINT `FK_MAG_CAT_CMP_ITEM_CSTR_ID_MAG_CSTR_ENTT_ENTT_ID` FOREIGN KEY (`customer_id`) REFERENCES `customer_entity` (`entity_id`) ON DELETE CASCADE ON UPDATE CAS) 

最佳答案

您应该尝试在禁用 session 的外键检查约束后进行导入。

SET FOREIGN_KEY_CHECKS=0;

将以上行放在您要导入的 sql 转储的顶部,然后再次尝试导入。

关于mysql - 无法添加或更新子行: a foreign key constraint fails in magetno,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27633062/

相关文章:

php - PDO::bindValue 未定义

mysql - R和RMySQL,如何获取连接的数据库名称?

magento - 如何在 Magento 中使用电子邮件模板

php - Zend Jalali 日期

database - magento - 迁移销售表

php - PHP MySQL 中的 Where 子句不能与 Like 关键字一起使用

sql - 如何计算 MySQL 中结果中的结果?

php - 在提交表单之前检查是否已填写某些字段

javascript - 玛根托 "Miscellaneous scripts"

Magento Authorize.net Direct Post 未清空购物车(未将报价设置为非事件状态)