Skip to content

Instantly share code, notes, and snippets.

@thomasheller
Created May 20, 2020 13:01
Show Gist options
  • Save thomasheller/8f8cf16fe7953b48da72240975fd8743 to your computer and use it in GitHub Desktop.
Save thomasheller/8f8cf16fe7953b48da72240975fd8743 to your computer and use it in GitHub Desktop.
Drop all tables in MySQL database
echo 'SET FOREIGN_KEY_CHECKS = 0;' > tmp.sql
mysqldump --add-drop-table --no-data <user, password, db> | grep 'DROP TABLE' >> tmp.sql
echo 'SET FOREIGN_KEY_CHECKS = 1;' >> tmp.sql
mysql <user, password, db> < tmp.sql
rm tmp.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment