Skip to content

Instantly share code, notes, and snippets.

@theel0ja
Forked from enoch85/mysql_secure.sh
Last active May 8, 2018 17:57
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 theel0ja/b1f58cb8b0e0030bfb3ad2394e748fe6 to your computer and use it in GitHub Desktop.
Save theel0ja/b1f58cb8b0e0030bfb3ad2394e748fe6 to your computer and use it in GitHub Desktop.
Automating mysql_secure_installation for MySQL 5.7
#!/bin/bash
apt-get -y install expect
SECURE_MYSQL=$(expect -c "
set timeout 10
spawn mysql_secure_installation
expect \"Enter current password for root:\"
send \"$MYSQL\r\"
expect \"Would you like to setup VALIDATE PASSWORD plugin?\"
send \"n\r\"
expect \"Change the password for root ?\"
send \"n\r\"
expect \"Remove anonymous users?\"
send \"y\r\"
expect \"Disallow root login remotely?\"
send \"y\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"
apt-get -y purge expect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment