Skip to content

Instantly share code, notes, and snippets.

@danthedaniel
Created February 17, 2018 20:43
Show Gist options
  • Save danthedaniel/df9a652a7c53d2bd95e3c27ffc3311dd to your computer and use it in GitHub Desktop.
Save danthedaniel/df9a652a7c53d2bd95e3c27ffc3311dd to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ ! -z "$1" -a ! -z "$2" -a ! -z "$3" ]; then
psql -c "CREATE USER $1 WITH PASSWORD '$2'"
psql -c "CREATE DATABASE $3"
psql -c "GRANT ALL PRIVILEGES ON DATABASE $3 to $1"
else
echo "Usage: new [user] [password] [database]"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment