Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.