TL;DR; Creating User, Database and Grant Access on PostgreSQL

Here is a simple snippet for creating user, database and grant access to that table on PostgreSQL.

Valid as of 2022-04-12 - PostgreSQL 14.1.

$ sudo su postgres
$ psql
postgres=# CREATE DATABASE db;
postgres=# CREATE USER user WITH ENCRYPTED PASSWORD 'super-secret';
postgres=# GRANT ALL PRIVILEGES ON DATABASE db TO user;

Greetings! 🌟 Berkcan here, your friendly neighborhood Full Stack Developer. I have a passion for discovering and tinkering with bleeding-edge tech.


There are a number of ways to grant access to PostgreSQL. This article will describe the basic ways and come up with an example.