0

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) 
Community
  • 1
  • 1
Phani Kumar
  • 71
  • 2
  • 10
  • possible duplicate of [ERROR 1452: Cannot add or update a child row: a foreign key constraint fails](http://stackoverflow.com/questions/16447137/error-1452-cannot-add-or-update-a-child-row-a-foreign-key-constraint-fails) – Aditya Dec 24 '14 at 07:22
  • there is another table which has to be updated before you can run this script. where did you find those sql dumps. from the majento site or other sources – Aniruddha K.M Dec 24 '14 at 07:23
  • @war_Hero those dumps from magento site. i am importing backup file to my new magento instance – Phani Kumar Dec 24 '14 at 07:31
  • try running the dumps for the customer_entity table first and see – Aniruddha K.M Dec 24 '14 at 07:36

1 Answers1

1

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.

Haleemur Ali
  • 26,718
  • 5
  • 61
  • 85