0

I exported with phpmyadmin my database with the options disable foreign keys and execute into a single transaction and drop table if exists, but when I want to import the file mysql throw an error:

ERROR 1215 (HY000) at line 35: Cannot add foreign key constraint

I checked the export file and seems to be ok. It starts with:

SET SQL_MODE = "";

SET AUTOCOMMIT = 0;
START TRANSACTION;
SET FOREIGN_KEY_CHECKS=0;
SET time_zone = "+00:00";

Mysql version is 5.6

Anyone knows what the problem is?

Thank you.

  • 1
    Check these links [First Link](http://stackoverflow.com/questions/15534977/mysql-cannot-add-foreign-key-constraint) , [Second](http://stackoverflow.com/questions/18930084/mysql-error-1215-hy000-cannot-add-foreign-key-constraint) , [Third](http://stackoverflow.com/questions/16969060/mysql-error-1215-cannot-add-foreign-key-constraint). – Kaushik Dec 16 '15 at 10:56
  • Please give example input that causes this error with this code. A FK declaration says subrow values in the referencing table must be in the referenced table. Is this so? – philipxy Dec 17 '15 at 23:13

1 Answers1

0

Are you importing the tables with data inside? Try to import just the structure, without the data. I had a similar problem, and it was because of this.

user2435860
  • 778
  • 3
  • 9
  • 22
  • I have data too. I want to preserve them. I tried to have 2 exports, one with the structure and one with the data, but it will throw the same errors when I want to execute the one with the structure only. – Ovidiu Iordache Dec 16 '15 at 11:28