Thomas Hunter II
Thomas Hunter II

Reputation: 5181

Copy Database using phpMyAdmin fails due to Foreign Key Constraints

I'm using phpMyAdmin, and I'm attempting to duplicate the database from one database to another (on my dev machine). I get the following error:

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

Behind the scenes, PMA appears to be doing a INSERT INTO ... SELECT query.

Is there a way to get PMA to copy this database properly? Or, is there a better tool for working with MySQL that I should be using (preferably GUI based)?

Upvotes: 5

Views: 3096

Answers (1)

Eugen Rieck
Eugen Rieck

Reputation: 65274

Export the original DB, then import it to new DB - the SQL created in the export will have a "disable keys" directive, that will lift you over the hurdle.

Upvotes: 4

Related Questions