Force drop mysql bypassing foreign key constraint Force drop mysql bypassing foreign key constraint mysql mysql

Force drop mysql bypassing foreign key constraint


This might be useful to someone ending up here from a search.Make sure you're trying to drop a table and not a view.

SET foreign_key_checks = 0;-- Drop tablesdrop table ...-- Drop viewsdrop view ...SET foreign_key_checks = 1;

SET foreign_key_checks = 0 is to set foreign key checks to off and then SET foreign_key_checks = 1 is to set foreign key checks back on. While the checks are off the tables can be dropped, the checks are then turned back on to keep the integrity of the table structure.


If you are using phpmyadmin then this feature is already there.

  • Select the tables you want to drop
  • From the dropdown at the bottom of tables list, select drop
  • A new page will be opened having checkbox at the bottom saying"Foreign key check", uncheck it.
  • Confirm the deletion by accepting "yes".


You can use the following steps, its worked for me to drop table with constraint,solution already explained in the above comment, i just added screen shot for that -enter image description here