How to disable or remove foreign key before importing database to phpmyadmin?

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?


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

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

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


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


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

GO to export in in phpmyadmin follow below step.

enter image description here

enter image description here

Similar questions

Magento 1.9 database import error in PhpMyadmin
When I am trying to import SQL file to database in to PhpMyAdmin I am receiving below error message.
Import Database to phpmyadmin from live server
I download/export the database file from live server and change domain name i.e localhost/foldername ao when i import the database to my local server phpmyadmin it gives sql import errors in queries how to resolve??
Entire database is not exporting from phpmyadmin in Xampp
The database is not exporting completely from phpmyadmin in my local server xampp. Please tell me the way to export the entire database.
Removing foreign accented characters before saving an Order in Magento
I have a problem wherein my Orders in Magento sometimes have shipping and billing address and name with foreign accents like àòèù. I want to convert them to English alphabets aoeu before saving the order in Magento. I have the php code for it, which is a function and I use this function in the OnepageController saveShippingAction method like before...
Setting a product to in-stock raises foreign key exception
When executing the following: For a very small amount of products (~13 or so) in the store (~10k SKUs) the following exception is raised: Again, this is a very small number of items many of which are defunct. There have been no manual db edits, but, I'm curious if there are others that have this issue that I don't/won't know about. Is there a way t...
Unable to reindex Product Prices - Foreign Key Constraint Fails
I've just recently upgraded my magento store from 1.4.2 to And The upgrade went smoothly but when I try to reindex data after the upgrade.. It fails on the Product Prices.. I've tried using php shell/indexer.php --reindexall from SSH and it fails at the Product Prices with these errors (I use pastebin as the error are quite long): http://...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.