-
-
Save nalipaz/1e091028d49f9a9c010fd82d6617be7f to your computer and use it in GitHub Desktop.
Automating mysql_secure_installation on MariaDB in CentOS 7
This file contains 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 | |
MARIADB_ROOT_PASS=abcd1234 | |
SECURE_MYSQL=$(expect -c " | |
set timeout 3 | |
spawn mysql_secure_installation | |
expect \"Enter current password for root (enter for none):\" | |
send \"\r\" | |
expect \"Set root password? \[Y/n\]\" | |
send \"y\r\" | |
expect \"New password:\" | |
send \"${MARIADB_ROOT_PASS}\r\" | |
expect \"Re-enter new password:\" | |
send \"${MARIADB_ROOT_PASS}\r\" | |
expect \"Remove anonymous users? \[Y/n\]\" | |
send \"y\r\" | |
expect \"Disallow root login remotely? \[Y/n\]\" | |
send \"n\r\" | |
expect \"Remove test database and access to it? \[Y/n\]\" | |
send \"y\r\" | |
expect \"Reload privilege tables now? \[Y/n\]\" | |
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