Advertisement
Guest User

Untitled

a guest
May 6th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. # mysql password update & mysql_secure_installation
  2. sudo yum -y update
  3. sudo yum -y install expect
  4. read -p "Type the password you want root to use for MySQL here: " MYSQLPASS
  5. echo "MySQL is being secured, this may take a moment..."
  6. SECURE_MYSQL=$(expect -c "
  7. set timeout 10
  8. spawn mysql_secure_installation
  9. expect \"Enter current password for root:\"
  10. #send \"CURRENT-PASSWD\r\" (if there is a passwd set, use this and comment out below)
  11. send \"\r\"
  12. #expect \"Would you like to setup VALIDATE PASSWORD plugin?\"
  13. #send \"n\r\"
  14. expect \"Change the password for root ?\"
  15. send \"y\r\"
  16. send \"$MYSQLPASS\r\"
  17. send \"$MYSQLPASS\r\"
  18. expect \"Remove anonymous users?\"
  19. send \"y\r\"
  20. expect \"Disallow root login remotely?\"
  21. send \"y\r\"
  22. expect \"Remove test database and access to it?\"
  23. send \"y\r\"
  24. expect \"Reload privilege tables now?\"
  25. send \"y\r\"
  26. expect eof
  27. ")
  28. echo "$SECURE_MYSQL"
  29. sudo yum -y remove expect
  30.  
  31. # MySQL change passwd for OTHERUSER
  32. #mysql -u root mysql -p$MYSQLPASS -e "update mysql.user set password=PASSWORD('$NCPASS') where User='OTHERUSER';"
  33. #mysql -u root -p$MYSQLPASS -e "flush privileges;"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement