Database 2019. 12. 4. 14:40
#!/bin/bash

OLD_DB=$1
NEW_DB=$2
USER=samsung

read -s -p "MySQL $USER Password: " PASS
echo "CREATE DATABASE $2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;" | mysql -u $USE
R --password=$PASS

TABLES=`echo "SHOW TABLES IN $1;" | mysql -NB -u $USER --password=$PASS`

for TABLE in $TABLES; do
    $(echo "RENAME TABLE \`$1\`.\`$TABLE\` TO \`$2\`.\`$TABLE\`;" | mysql -u $USER --password=$PASS)
done
posted by 사용자 kimsooil

댓글을 달아 주세요