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;