Skip to content

Instantly share code, notes, and snippets.

@LukaSikic
Created July 28, 2018 22:21
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 LukaSikic/61acc0251e7211ca907241bdc3d384c1 to your computer and use it in GitHub Desktop.
Save LukaSikic/61acc0251e7211ca907241bdc3d384c1 to your computer and use it in GitHub Desktop.
Automated mysql_secure_installation ubuntu 18.04
SECURE_MYSQL=$(expect -c "
set timeout 10
spawn mysql_secure_installation
expect \"Press y|Y for Yes, any other key for No:\"
send \"n\r\"
expect \"New password:\"
send \"123456\r\"
expect \"Re-enter new password:\"
send \"123456\r\"
expect \"Remove anonymous users? (Press y|Y for Yes, any other key for No) :\"
send \"y\r\"
expect \"Disallow root login remotely? (Press y|Y for Yes, any other key for No) :\"
send \"y\r\"
expect \"Remove test database and access to it? (Press y|Y for Yes, any other key for No) :\"
send \"y\r\"
expect \"Reload privilege tables now? (Press y|Y for Yes, any other key for No) :\"
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