Last active
August 29, 2015 14:08
-
-
Save 3mcd/1759e360883c903bd1ce to your computer and use it in GitHub Desktop.
Drop all tables from MySQL db
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Credit to Lon F. Binder at http://www.cyberciti.biz/faq/how-do-i-empty-mysql-database/#comment-43783