Disable foreign key checks in MySQL


Another short article in which I'm going to show you how to disable foreign key checks in mysql. Let's go!

Sometimes you want to just import a mysql dump or have to do something else in your database that conflicts with the foreign keys. For this reason there is the option of disabling foreign key checks when running a SQL script.

-- disable foreign key checks

-- your sql code here

-- enable foreign key checks again

-- more sql code or nothing

And that's it! Now you can switch this option whenever you need it! 👍