- 
      
 - 
        
Save klevisndoka/9f7bfd80a8782b22f1bbce548db2792b to your computer and use it in GitHub Desktop.  
    Automating mysql_secure_installation
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| yum -y install expect | |
| MYSQL_ROOT_PASSWORD=root | |
| SECURE_MYSQL=$(expect -c " | |
| set timeout 10 | |
| spawn mysql_secure_installation | |
| expect \"Enter current password for root (enter for none):\" | |
| send \"\r\" | |
| expect \"Set root password?\" | |
| send \"y\r\" | |
| expect \"New password:\" | |
| send \"$MYSQL_ROOT_PASSWORD\r\" | |
| expect \"Re-enter new password:\" | |
| send \"$MYSQL_ROOT_PASSWORD\r\" | |
| expect \"Remove anonymous users?\" | |
| send \"y\r\" | |
| expect \"Disallow root login remotely?\" | |
| send \"n\r\" | |
| expect \"Remove test database and access to it?\" | |
| send \"y\r\" | |
| expect \"Reload privilege tables now?\" | |
| send \"y\r\" | |
| expect eof | |
| ") | |
| echo "$SECURE_MYSQL" | |
| yum -y remove expect | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment