Created
November 29, 2012 00:54
-
-
Save mweppler/4165957 to your computer and use it in GitHub Desktop.
Drop mysql tables in given database
This file contains hidden or 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
#!/bin/bash | |
USER="$1" | |
PASS="$2" | |
DB="$3" | |
if [ $# -ne 3 ] | |
then | |
echo "Usage: $0 {MySQL-User-Name} {MySQL-User-Password} {MySQL-Database-Name}" | |
echo "Drops all tables from a MySQL" | |
exit 1 | |
fi | |
for i in `mysql -u$USER -p$PASS $DB -e 'show tables' | awk '{ print $1}' | ack -v '^Tables'`; do mysql -u$USER -p$PASS $DB -e "drop table \`$i\`"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment