Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)?

like image 231
Thomas Hunter II Avatar asked Oct 09 '22 04:10

Thomas Hunter II


1 Answers

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.

like image 174
Eugen Rieck Avatar answered Oct 13 '22 11:10

Eugen Rieck