I am trying to move the site from my localhost to the server but um getting an error message that does not allow me to import the database:
ERROR 1452 (23000) at line 119329: Cannot add or update a child row: a foreign key constraint fails (`goodnews_magento`.`#sql-15b05_2226f`, CONSTRAINT `FK_CATALOG_EAV_ATTRIBUTE_ATTRIBUTE_ID_EAV` FOREIGN KEY (`attribute_id`) REFERENCES `eav_attribute` (`attribute_id`) ON DELETE CASCADE ON UPDA)
MAny thanks
14 answers
Hi alvaroadair,
Look the content you shared, i see you missing the chars `--` at before the texts `phpMyAdmin SQL Dump`.
Regards,
Mall.
Hi alvaroadair,
To solve the issue as you mentioned, Before import to the new database instance, let’s add below sql lines in the head content of the sql file you have exported:
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET FOREIGN_KEY_CHECKS=0;
And re-import the sql file after your changing.
Regards,
Mall.
Hi Alvaroadair,
As Mall suggested, you can enter the code into the top of your SQL file (the file you exported from your localhost instance).
Once done, you import this modified SQL file to your live server.
Hope that helps.
Regards,
An Nguyen
I inserted the code and I am getting this error from the outset:
SQL query:
phpMyAdmin SQL Dump
-- version 4.4.15.8
-- https://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Oct 26, 2016 at 09:50 AM
-- Server version: 5.6.31
-- PHP Version: 5.6.25
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
MySQL said:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'phpMyAdmin SQL Dump
-- version 4.4.15.8
-- https://www.phpmyadmin.net
--
-- Host' at line 1
Hi alvaroadair,
I need a closer look to detect the root of issue as you said. Can you provide me your sql file?
Regards,
Mall.
--phpMyAdmin SQL Dump -- already had — before it, I added another 2 (—-) and that did the trick.
—-phpMyAdmin SQL Dump
Thanks
I managed to import the database by adding SET FOREIGN_KEY_CHECKS= “0”; do in need to change anything after the database has been imported?
Hi alvaroadair ,
After imported your database successfully. Let’s run more below SQL command in your database:
SET FOREIGN_KEY_CHECKS=1;
Regards,
Mall.
Hi Mall,
Tried that -- MySQL returned an empty result set (i.e. zero rows). (Query took 0.0000 seconds.)
Hi guy,
The message should be as this: http://i.prntscr.com/111deeeb08ad41209426144d9e74feb3.png
Regards,
Mall.
Hi Mall, as I was copying and pasting the query MySQL was not happy with that hence the reason it did not update it, after typing it worked a treat, thanks for ALL your help. SET FOREIGN_KEY_CHECKS=1;
Hi alvaroadair,
Great to hear that sound. Let’s contact me if you need further assistance!
Regards,
Mall.
I will, Thank you.
This question is now closed