After installation of postgres, login using superuser.
sudo su - postgres
List all the databases" \l
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_IN.UTF-8 | en_IN.UTF-8 |
template0 | postgres | UTF8 | en_IN.UTF-8 | en_IN.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_IN.UTF-8 | en_IN.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
List all the users: \du
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
Create user
postgres=# CREATE USER root;
CREATE ROLE
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
root | | {}
Alter user
postgres=# Alter user root with Superuser;
ALTER ROLE
Update config: sudo vim /etc/postgresql/12/main/pg_hba.conf