0

I was uploading localhost site to live server. During the process I was importing .sql file from localhost to PHPMyAdmin live server database. After the uploading process was complete I got an error of:

Error message

SQL query:

ALTER TABLE `core_email_queue_recipients`
ADD CONSTRAINT `FK_6F4948F3ABF97DE12127EF14B140802A`
FOREIGN KEY (`message_id`) REFERENCES `core_email_queue` (`message_id`)
ON DELETE CASCADE ON UPDATE CASCADE

MySQL said:

#1452 - Cannot add or update a child row: a foreign key constraint fails (`buddydea_magento`.`#sql-2aae_84a13f`, CONSTRAINT `FK_6F4948F3ABF97DE12127EF14B140802A` FOREIGN KEY (`message_id`) REFERENCES `core_email_queue` (`message_id`) ON DELETE CASCADE ON UPDATE CASC)

I have looked for the solution but didn't find the right answer.

Please help me to remove this error.

asked Jul 7, 2017 at 16:09
1
  • did you have ssh access? run commad mysqldump and import database Commented Jul 20, 2017 at 15:24

2 Answers 2

0

Excute below query before upload

SET FOREIGN_KEY_CHECKS=0;

Once uploaded revert back

SET FOREIGN_KEY_CHECKS=1;
answered Jul 7, 2017 at 16:12
19
  • how should i do this. Commented Jul 7, 2017 at 16:15
  • go to sql tab and run the query Commented Jul 7, 2017 at 16:20
  • I just have to go sql tab and run this command ? Commented Jul 7, 2017 at 16:26
  • yes. just goo to the sql tab and past the SET FOREIGN_KEY_CHECKS=0; then click 'go' button Commented Jul 7, 2017 at 16:28
  • Did you get my point? Commented Jul 7, 2017 at 16:34
0

I have found that if I export from phpmysql, even with "disable foreign key checks" set both at export and import, my import has been failing. Phpmysql is exporting in an order that makes no sense, creating the keys too early, or not destroying them when dropping the tables, and not ignoring the checks totally.

BUT THERE IS A WAY - if I export the database from within Magento's Backup tool - that file imports in phpmyadmin without errors.

Wish I'd tried that earlier

answered Jul 20, 2017 at 15:20

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.