Postgres Snippets

Postgres shell

psql postgres

Create User and Database

Create user webapp, database webappdb and grant all privileges to user.

To generate random passwords I use: https://passwordsgenerator.net/

CREATE DATABASE webappdb;

CREATE USER webapp WITH PASSWORD 'DXw3BzFsNERfPwjg';

GRANT ALL PRIVILEGES ON DATABASE "webappdb" TO "webapp";

Grant read-only permission

Grant read-only permission to user webapp_ro to database webappdb

GRANT SELECT ON ALL TABLES IN SCHEMA webappdb TO webapp;