#!/bin/sh # _ :: database [username password] # create the sql to create a database in mariadb and a user that has all privileges on the database. # username and password are optional. if username is ommited it is set to the database name. # if password is ommitted it is set to the username. if test $# -eq 0 then echo usage: database_name username password exit fi if test $# -eq 1 then database=$1 username=$1 password=$1 elif test $# -eq 2 then database=$1 username=$2 password=$2 elif test $# -eq 3 then database=$1 username=$2 password=$3 fi echo "create database $database charset=utf8mb4;" echo "create user if not exists '$username'@'localhost' identified by '$password';" echo "grant all privileges on $database.* to '$username'@'localhost';" echo "flush privileges;"