Created
August 31, 2021 14:00
-
-
Save silviud/dd2caaf018c4d2816b8d82397dd3e768 to your computer and use it in GitHub Desktop.
Create postgresql role and database from shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create password - note the md5 is the prefix and the value is user + password | |
$ U=testpg; P=testpg; echo -n md5; echo -n $P$U | md5sum | cut -d' ' -f1 | |
$ md54bb01023735acf990f528fe961df8140 | |
# connect to pg | |
$ psql | |
postgres=# CREATE ROLE testpg NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT LOGIN PASSWORD 'md54bb01023735acf990f528fe961df8140'; | |
postgres=# CREATE DATABASE testpgdb OWNER testpg; | |
^D | |
# at this point you can connect to the database `testpgdb` such so | |
$ psql -U testpg -d testpgdb -h YOURHOST -W |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment