Phani Kumar
Phani Kumar

Reputation: 71

Cannot add or update a child row: a foreign key constraint fails in magetno

I am trying to import sql dump using phpmyadmin. i am getting the following error

Constraints for table 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) 

Upvotes: 0

Views: 1341

Answers (1)

Haleemur Ali
Haleemur Ali

Reputation: 28293

You should try to do the import after disabling foreign key check constraints for the session.

SET FOREIGN_KEY_CHECKS=0;

Place the above line at the top of the sql dump which you're import and try the import again.

Upvotes: 1

Related Questions