Skip to content

Instantly share code, notes, and snippets.

@3mcd
Last active August 29, 2015 14:08
Show Gist options
  • Save 3mcd/1759e360883c903bd1ce to your computer and use it in GitHub Desktop.
Save 3mcd/1759e360883c903bd1ce to your computer and use it in GitHub Desktop.
Drop all tables from MySQL db
mysql --user=YOUR_USERNAME --password=YOUR_PASSWORD -BNe "show tables" YOUR_DBSCHEMA_NAME | tr '\n' ',' | sed -e 's/,$//' | awk '{print "SET FOREIGN_KEY_CHECKS = 0;DROP TABLE IF EXISTS " $1 ";SET FOREIGN_KEY_CHECKS = 1;"}' | mysql --user=YOUR_USERNAME --password=YOUR_PASSWORD YOUR_DBSCHEMA_NAMEt
@3mcd
Copy link
Author

3mcd commented Oct 24, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment