1

We can import any heavy database into phpmyadmin from command prompt. But many tables have foreign key and it is not allowed to insert a table having foreign key. So how to remove or disable foreign key in order to import database in phpmyadmin?

3 Answers 3

4

Ya, we can set foreign key check as disable before importing database into phpmyadmin.

What we need to do is, edit that database file i.e. yourdatabase.sql and add 2 lines in it.

1) Add in just beginning of database file

SET FOREIGN_KEY_CHECKS = 0;

2) Just before end of file at last line of file.

SET FOREIGN_KEY_CHECKS = 1;

First it will disable foreign key checks and in the end, it will enable it again.

0

GO to export in in phpmyadmin follow below step.

enter image description here

enter image description here

0

You can also set it from the commandline directly into the mysql command.

mysql --init-command="SET SESSION FOREIGN_KEY_CHECKS=0;" ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.