Skip to content

Instantly share code, notes, and snippets.

@cyhook
Forked from omeinusch/create-mysql.bash
Created June 27, 2018 07:15
Show Gist options
  • Select an option

  • Save cyhook/2dbd4a6395e6f90f90daddd9c5f89109 to your computer and use it in GitHub Desktop.

Select an option

Save cyhook/2dbd4a6395e6f90f90daddd9c5f89109 to your computer and use it in GitHub Desktop.

Revisions

  1. @omeinusch omeinusch revised this gist Aug 31, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion create-mysql.bash
    Original file line number Diff line number Diff line change
    @@ -10,4 +10,4 @@ MYSQL_SCRIPT

    echo "MySQL user created."
    echo "Username: $1"
    echo "Password: $PASS"
    echo "Password: $PASS"
  2. @omeinusch omeinusch created this gist Aug 31, 2013.
    13 changes: 13 additions & 0 deletions create-mysql.bash
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    #!/bin/bash
    PASS=`pwgen -s 40 1`

    mysql -uroot <<MYSQL_SCRIPT
    CREATE DATABASE $1;
    CREATE USER '$1'@'localhost' IDENTIFIED BY '$PASS';
    GRANT ALL PRIVILEGES ON $1.* TO '$1'@'localhost';
    FLUSH PRIVILEGES;
    MYSQL_SCRIPT

    echo "MySQL user created."
    echo "Username: $1"
    echo "Password: $PASS"