Skip to content

Instantly share code, notes, and snippets.

@remoteur
Created March 20, 2015 00:56
Show Gist options
  • Save remoteur/70ffa33f234a4b8fa00c to your computer and use it in GitHub Desktop.
Save remoteur/70ffa33f234a4b8fa00c to your computer and use it in GitHub Desktop.
db_create
#!/bin/bash
db=$1
pass=$(openssl rand -hex 10)
mysql -e "CREATE DATABASE $1"
mysql -e "GRANT ALL PRIVILEGES ON $db.* TO '$db'@'localhost' IDENTIFIED BY '$pass';"
mysql -e "GRANT ALL PRIVILEGES ON $db.* TO '$db'@'%' IDENTIFIED BY '$pass';"
echo $pass > .$db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment