HostKnox Inc
  • 20Gb Disk Space
  • Unmetered Bandwidth
  • Free Website Transfer
  • Free Script Installation
  • Unique Control Panel
  • 24/7 Professional Support
Please Log In
Sign Up

Quick Navigation

Client Login

Email

Password

Remember Me

Search



Follow Us on Twitter

Knowledgebase

How to fix the error "1452 - Cannot add or update a child row: a foreign key constraint fails" in Magento

When importing your Magento database into a new one, for example when moving from one host to another, you may get this error:

1452 - Cannot add or update a child row: a foreign key constraint fails

To fix the error and import the database properly, you need to disable foreign key checks. In phpMyAdmin this can be done by ticking the box next to:

Disable foreign key checks

in the Options section of the phpMyAdmin Export window. Then you can safely export the original database and import it into the new one.

If you don't have access to or you don't want to use phpMyAdmin but you have an existing database dump that fails to import because of the error above, you can disable foreign key checks directly in the database dump. You can do this by opening the dump with a text editor and pasting the following line at the beginning of the file:

SET foreign_key_checks=0;

Save the file and try importing it again; the import process should go through without any problems.


Was this answer helpful?

Also Read