Skip to content

Instantly share code, notes, and snippets.

@mweppler
Created November 29, 2012 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mweppler/4165957 to your computer and use it in GitHub Desktop.
Save mweppler/4165957 to your computer and use it in GitHub Desktop.
Drop mysql tables in given database
#!/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