Skip to content

Instantly share code, notes, and snippets.

@andrewvmail
Forked from Mins/mysql_secure.sh
Last active May 21, 2019 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewvmail/3f03c0bc1f281ffc63b18091de9ffc72 to your computer and use it in GitHub Desktop.
Save andrewvmail/3f03c0bc1f281ffc63b18091de9ffc72 to your computer and use it in GitHub Desktop.
Automating mysql_secure_installation
#!/bin/bash
set -x
SECURE_MYSQL=$(expect -c "
set timeout 10
spawn mysql_secure_installation
expect \"Would you like to setup VALIDATE PASSWORD plugin?\"
send \"n\r\"
expect \"New password:\"
send \"abc\r\"
expect \"Re-enter new password: \"
send \"abc\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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment