Created
April 5, 2019 02:22
-
-
Save so-jelly/bb2a5a19bbcd19fd7abd9656d27570ff to your computer and use it in GitHub Desktop.
MySQL Drop all tables
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
# need a backup? | |
## mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -h$MYSQL_HOST $MYSQL_DATABASE | gzip > $(date +%s).sql.tgz | |
echo 'SET FOREIGN_KEY_CHECKS = 0;' > drop_all_tables.sql | |
mysqldump --add-drop-table --no-data -u$MYSQL_USER -p$MYSQL_PASSWORD -h$MYSQL_HOST $MYSQL_DATABASE \ | |
| grep 'DROP TABLE' >> drop_all_tables.sql | |
echo 'SET FOREIGN_KEY_CHECKS = 1;' >> drop_all_tables.sql | |
mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -h$MYSQL_HOST $MYSQL_DATABASE < drop_all_tables.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment