#!/bin/bash # __ __ ______ __ __ __ __ __ __ # /\ "-.\ \ /\ ___\ /\ \ /\ \ /\ "-.\ \ /\ \/ / # \ \ \-. \ \ \ __\ \ \ \____ \ \ \ \ \ \-. \ \ \ _"-. # \ \_\\"\_\ \ \_\ \ \_____\ \ \_\ \ \_\\"\_\ \ \_\ \_\ # \/_/ \/_/ \/_/ \/_____/ \/_/ \/_/ \/_/ \/_/\/_/ # Adds a mysql user, and creates a database with the same name as the user and echos the generated password if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then echo "usage: ./$0 [mysql db username] [mysql user password] [new identifier] [optional password]" exit fi DB_PASSWORD=$(env LC_CTYPE=C tr -dc "a-zA-Z0-9-_\$\?" < /dev/urandom | head -c 16) DB_USER=$3 if [ -n "$4" ]; then DB_PASSWORD=$4 fi #sql for creating a user and a database CMD=$(cat <