Create Super User or Update User to Super User in PostgreSQL

In this tutorial, we are going to first create user. Then, upgrade it as super user. Then, we directly create super user.

1. Create user as super user.

postgres=#

create user pg_admin with password 'test@123' SUPERUSER;

To verify run the \du command in psql tool

List of roles Role name | Attributes | Member of ------------+------------------------------------------------------------+-------------- anil | | {} elchur | | {} john | | {webreaders} kalpesh | | {} michael | | {} pg_admin | Superuser | {} philip | | {} postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {} ramesh | | {} readonly | Cannot login | {} sachin | | {} sunil | | {} webreaders | Cannot login | {}

2. Create user and then upgrade to Super User.

a) Create normal user:

create user admin_pg with password 'test@123';

To verify run the \du command in psql tool

List of roles Role name | Attributes | Member of ------------+------------------------------------------------------------+-------------- admin_pg | | {} anil | | {} elchur | | {} john | | {webreaders} kalpesh | | {} michael | | {} pg_admin | Superuser | {} philip | | {} postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {} ramesh | | {} readonly | Cannot login | {} sachin | | {} sunil | | {} webreaders | Cannot login | {}

Notice that user admin_pg is not having any roles.

b) Now upgrade user to Super User.

alter user admin_pg with superuser;

To verify run the \du command in psql tool

List of roles Role name | Attributes | Member of ------------+------------------------------------------------------------+-------------- admin_pg | Superuser | {} anil | | {} elchur | | {} john | | {webreaders} kalpesh | | {} michael | | {} pg_admin | Superuser | {} philip | | {} postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {} ramesh | | {} readonly | Cannot login | {} sachin | | {} sunil | | {} webreaders | Cannot login | {}

Related Posts

CheapSexCams
Responses are currently closed, but you can trackback from your own site.

Comments are closed.

Powered by k2schools
%d bloggers like this: