Commands for Postgres DB initial setup

by Moondaddi on 2019-02-25


Create DB

postgres=# CREATE DATABASE [db_name];

Create User with Password

postgres=# CREATE USER [myuser] WITH ENCRYPTED PASSWORD '[password]';

Alter database owner

postgres=# ALTER DATABASE [db_name] OWNER TO [myuser];

Grant the privileges

postgres=# GRANT ALL PRIVILEGES ON DATABASE [db_name] TO [myuser];

Grant a permission to create DB to user

postgres=# ALTER USER [myuser] WITH CREATEDB;