Created
March 27, 2015 05:34
-
-
Save rubymerchant/28a154a90f53e30559ff to your computer and use it in GitHub Desktop.
Rename Database
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
#!/usr/bin/env bash | |
mysql -e "DROP DATABASE $2;" | |
mysql -e "CREATE DATABASE $2;" | |
for i in $(mysql -Ns $1 -e "show tables");do | |
echo "$1.$i -> $2.$i" | |
mysql -e "rename TABLE $1.$i to $2.$i" | |
done | |
mysql -e "DROP DATABASE $1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment