22 lines
396 B
Bash
Executable file
22 lines
396 B
Bash
Executable file
#!/bin/zsh
|
|
|
|
echo -n 'Database root PW (for DB creation): '
|
|
read -s ROOTPW
|
|
echo
|
|
|
|
echo -n 'Database user for new DB: '
|
|
read DBUSER
|
|
|
|
echo -n 'Database user PW for new DB: '
|
|
read -s DBPASSW
|
|
echo
|
|
|
|
mysql -u root -p"$ROOTPW" -B <<EOF
|
|
CREATE DATABASE $2;
|
|
GRANT ALL ON $2.* to '$DBUSER'@'localhost';
|
|
EOF
|
|
|
|
unset ROOTPW
|
|
|
|
mysqldump -u "$DBUSER" -p"$DBPASSW" "$1" \
|
|
| mysql -u "$DBUSER" -p"$DBPASSW" "$2"
|