Database 2019. 12. 5. 04: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

'Database' 카테고리의 다른 글

How to import JSON data into MongoDB using mongoimport  (0) 2019.12.04
posted by kimsooil

댓글을 달아 주세요