Skip to content

Instantly share code, notes, and snippets.

View kajsa's full-sized avatar

Kajsa Anderson kajsa

View GitHub Profile
@kajsa
kajsa / create-mysql.bash
Last active September 20, 2018 20:49 — forked from askz/create-mysql.bash
Simple bash script to create mysql db, user with generated password
#!/bin/bash
# The script will fail at the first error encountered
set -e
PASS=`openssl rand 15 -base64`
mysql -uroot <<MYSQL_SCRIPT
CREATE DATABASE $1;
CREATE USER '$1'@'localhost' IDENTIFIED BY '$PASS';
GRANT ALL PRIVILEGES ON $1.* TO '$1'@'localhost';