Skip to content

Instantly share code, notes, and snippets.

@jimrybarski
Forked from Mins/mysql_secure.sh
Last active January 1, 2016 22:19

Revisions

  1. jimrybarski revised this gist Jan 1, 2014. 1 changed file with 2 additions and 9 deletions.
    11 changes: 2 additions & 9 deletions mysql_secure.sh
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,12 @@
    #!/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\"
    send \"\r\"
    expect \"Change the root password?\"
    send \"n\r\"
    @@ -31,6 +26,4 @@ send \"y\r\"
    expect eof
    ")

    echo "$SECURE_MYSQL"

    aptitude -y purge expect
    echo "$SECURE_MYSQL"
  2. 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
  3. Mins renamed this gist Jan 23, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. 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