utilities/rebasedb

15 lines
291 B
Text
Raw Permalink Normal View History

2013-07-22 23:01:45 +02:00
#!/bin/zsh
echo -n 'Database root PW (for DB manipulation): '
read -s ROOTPW
echo
mysql -u root -p"$ROOTPW" -B <<EOF
DROP DATABASE $2; CREATE DATABASE $2;
EOF
echo "Recreated database $2"
mysqldump -u root -p"$ROOTPW" "$1" \
| mysql -u root -p"$ROOTPW" -B "$2"
echo "Copied $1 to $2"