Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- PW="password"
- DB="app_db"
- DBUSER="app"
- DBPWD="password2"
- expect -c "
- set timeout 10
- spawn mysql_secure_installation
- expect \"Enter current password for root (enter for none):\"
- send \"\n\"
- expect \"Set root password?\"
- send \"y\n\"
- expect \"New password:\"
- send \"${PW}\n\"
- expect \"Re-enter new password:\"
- send \"${PW}\n\"
- expect \"Remove anonymous users?\"
- send \"y\n\"
- expect \"Disallow root login remotely?\"
- send \"y\n\"
- expect \"Remove test database and access to it?\"
- send \"y\n\"
- expect \"Reload privilege tables now?\"
- send \"y\n\"
- expect eof exit 0
- "
- mysql -u root --password=${PW} <<EOF
- SET storage_engine=INNODB;
- CREATE DATABASE IF NOT EXISTS ${DB} DEFAULT CHARACTER SET utf8;
- GRANT ALL PRIVILEGES ON ${DB}.* TO '${DBUSER}'@'localhost' IDENTIFIED BY '${DBPWD}';
- SET PASSWORD FOR '${DBUSER}'@'localhost' = PASSWORD('${DBPWD}');
- FLUSH PRIVILEGES;
- USE ${DB};
- # SOURCE /var/www/.migration/db_migration.sql;
- EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement