Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. PW="password"
  4.  
  5. DB="app_db"
  6. DBUSER="app"
  7. DBPWD="password2"
  8.  
  9. expect -c "
  10. set timeout 10
  11. spawn mysql_secure_installation
  12. expect \"Enter current password for root (enter for none):\"
  13. send \"\n\"
  14. expect \"Set root password?\"
  15. send \"y\n\"
  16. expect \"New password:\"
  17. send \"${PW}\n\"
  18. expect \"Re-enter new password:\"
  19. send \"${PW}\n\"
  20. expect \"Remove anonymous users?\"
  21. send \"y\n\"
  22. expect \"Disallow root login remotely?\"
  23. send \"y\n\"
  24. expect \"Remove test database and access to it?\"
  25. send \"y\n\"
  26. expect \"Reload privilege tables now?\"
  27. send \"y\n\"
  28. expect eof exit 0
  29. "
  30.  
  31. mysql -u root --password=${PW} <<EOF
  32. SET storage_engine=INNODB;
  33. CREATE DATABASE IF NOT EXISTS ${DB} DEFAULT CHARACTER SET utf8;
  34. GRANT ALL PRIVILEGES ON ${DB}.* TO '${DBUSER}'@'localhost' IDENTIFIED BY '${DBPWD}';
  35. SET PASSWORD FOR '${DBUSER}'@'localhost' = PASSWORD('${DBPWD}');
  36. FLUSH PRIVILEGES;
  37. USE ${DB};
  38. # SOURCE /var/www/.migration/db_migration.sql;
  39. EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement