Last active
October 10, 2019 14:38
-
-
Save gwagroves/3fd1c8c2a342826671c0c17a42cd43b1 to your computer and use it in GitHub Desktop.
MySQL drop all tables from a database
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
# The following assumes credentials are saved in .my.cnf (or similar) | |
# | |
# Create a file with a drop table command for each table. | |
# (Replace "database" with the name of the database.) | |
# | |
mysqldump --add-drop-table --no-data database | grep 'DROP TABLE' > ~/little_bobby_tables.sql | |
# Check. | |
# | |
cat ~/little_bobby_tables.sql | |
# Run the commands. | |
# | |
mysql database < ~/little_bobby_tables.sql | |
# Remove that dangerous file! | |
# | |
rm ~/little_bobby_tables.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment