Create Postgres Role

Connected with the psql client, we’ll create a role that has the LOGIN attribute and having MD5-encrypted password:

postgres=# CREATE ROLE role1 WITH LOGIN ENCRYPTED PASSWORD 'role1 ';
List available roles ant their privileges
postgres=# \du
 List of roles
 Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
 postgres | Superuser, Create role, Create DB, Replication | {}

postgres=# CREATE ROLE role1 WITH LOGIN ENCRYPTED PASSWORD 'role1 ';

postgres=# \du
 List of roles
 Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
 postgres | Superuser, Create role, Create DB, Replication | {}
 role1 | | {}

Allow role to access database

grant ALL ON DATABASE <database_name> TO <role_nae>;