Getting an error message during import

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

Profile photo of Mall Staff 184060.00 $tone October 26, 2016
Public

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.

#1
Profile photo of Admin Staff -30640.00 $tone October 26, 2016
Public

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

#3
Profile photo of alvaroadair 750.00 $tone October 26, 2016
Public

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: Documentation
#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

#4
Profile photo of alvaroadair 750.00 $tone October 26, 2016
Public

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; 

#11

This question is now closed

Written By

Comments