Skip to content

Instantly share code, notes, and snippets.

@rbarros
Forked from enoch85/mysql_secure.sh
Created June 1, 2016 13:49
Show Gist options
  • Select an option

  • Save rbarros/c47b9eda3b0f5289b6574f7443f51d7c to your computer and use it in GitHub Desktop.

Select an option

Save rbarros/c47b9eda3b0f5289b6574f7443f51d7c to your computer and use it in GitHub Desktop.

Revisions

  1. Daniel Hansson revised this gist Feb 1, 2016. 1 changed file with 1 addition and 4 deletions.
    5 changes: 1 addition & 4 deletions mysql_secure.sh
    Original file line number Diff line number Diff line change
    @@ -13,10 +13,7 @@ spawn mysql_secure_installation
    expect \"Enter current password for root:\"
    send \"$MYSQL\r\"
    expect \"VALIDATE PASSWORD PLUGIN can be used to test passwords
    and improve security. It checks the strength of password
    and allows the users to set only those passwords which are
    secure enough. Would you like to setup VALIDATE PASSWORD plugin?\"
    expect \"Would you like to setup VALIDATE PASSWORD plugin?\"
    send \"n\r\"
    expect \"Change the password for root ?\"
  2. Daniel Hansson revised this gist Feb 1, 2016. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions mysql_secure.sh
    Original file line number Diff line number Diff line change
    @@ -10,10 +10,16 @@ SECURE_MYSQL=$(expect -c "
    set timeout 10
    spawn mysql_secure_installation
    expect \"Enter current password for root (enter for none):\"
    expect \"Enter current password for root:\"
    send \"$MYSQL\r\"
    expect \"Change the root password?\"
    expect \"VALIDATE PASSWORD PLUGIN can be used to test passwords
    and improve security. It checks the strength of password
    and allows the users to set only those passwords which are
    secure enough. Would you like to setup VALIDATE PASSWORD plugin?\"
    send \"n\r\"
    expect \"Change the password for root ?\"
    send \"n\r\"
    expect \"Remove anonymous users?\"
  3. Mins revised this gist Jan 23, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mysql_secure.sh
    Original file line number Diff line number Diff line change
    @@ -33,4 +33,4 @@ expect eof

    echo "$SECURE_MYSQL"

    aptitude purge expect
    aptitude -y purge expect
  4. Mins renamed this gist Jan 23, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. Mins created this gist Jan 23, 2013.
    36 changes: 36 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    #!/bin/bash

    aptitude -y install expect

    // Not required in actual script
    MYSQL_ROOT_PASSWORD=abcd1234

    SECURE_MYSQL=$(expect -c "
    set timeout 10
    spawn mysql_secure_installation
    expect \"Enter current password for root (enter for none):\"
    send \"$MYSQL\r\"
    expect \"Change the root password?\"
    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"

    aptitude purge expect