Advertisement
Guest User

Untitled

a guest
Jan 28th, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. echo -e "nn$db_passn$db_passnnnnn" | /usr/bin/mysql_secure_installation
  2.  
  3. In order to log into MySQL to secure it, we'll need the current
  4. password for the root user. If you've just installed MySQL, and
  5. you haven't set the root password yet, the password will be blank,
  6. so you should just press enter here.
  7.  
  8. stty: standard input: Invalid argument
  9. Enter current password for root (enter for none):
  10. stty: standard input: Invalid argument
  11. OK, successfully used password, moving on...
  12.  
  13. Setting the root password ensures that nobody can log into the MySQL
  14. root user without the proper authorisation.
  15.  
  16. Set root password? [Y/n] ... skipping.
  17.  
  18. #!/usr/bin/expect --
  19. spawn /usr/local/mysql/bin/mysql_secure_installation
  20.  
  21. expect "Enter current password for root (enter for none):"
  22. send "r"
  23.  
  24. expect "Set root password?"
  25. send "yr"
  26.  
  27. expect "New password:"
  28. send "passwordr"
  29.  
  30. expect "Re-enter new password:"
  31. send "passwordr"
  32.  
  33. expect "Remove anonymous users?"
  34. send "yr"
  35.  
  36. expect "Disallow root login remotely?"
  37. send "yr"
  38.  
  39. expect "Remove test database and access to it?"
  40. send "yr"
  41.  
  42. expect "Reload privilege tables now?"
  43. send "yr"
  44.  
  45. puts "Ended expect script."
  46.  
  47. /usr/bin/mysql -uroot -e "DELETE FROM mysql.user WHERE User=''; DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1'); DROP DATABASE IF EXISTS test; FLUSH PRIVILEGES;"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement