Magento – Magento import tables from old database show error (errno: 150 “Foreign key constraint is incorrectly formed”)

databasemagento-1.9

i want to import old customer data to new magento store i have imported all customer's table instead of customer_entity, when i import this table i am getting this error

1005 – Can't create table test.customer_entity (errno: 150 "Foreign key constraint is incorrectly formed")

Please help me out for this issue.

Best Answer

This error could be due to several reasons but you are working with imported tables so try checking ENGINE and/or CHARSET parameters: It can happen you are trying to add a new table using a different one!

From: MySql - Using FOREIGN KEY Constraints

If you re-create a table that was dropped, it must have a definition that conforms to the foreign key constraints referencing it.

So if you are using a .sql file to import the customer's tables, open it and check it: at the end of queries there should be something like:

) ENGINE=InnoDB  DEFAULT CHARSET=latin1;

then be sure to use those same parameters for the new customer_entity table.

If the problem keep showing, check if foreign key column and the referencing have same column type or length, read more here.

Reed also here MariaDB: InnoDB foreign key constraint errors

Related Topic