Re: How to make superuser from non superuser in PostgreSQL - Mailing list pgsql-admin

From Muhammad Usman Khan
Subject Re: How to make superuser from non superuser in PostgreSQL
Date
Msg-id CAPnRvGs3f7zck7YM+efXgW0G9TrgxybouKf7XJzwkadQ7QrgDg@mail.gmail.com
Whole thread Raw
In response to How to make superuser from non superuser in PostgreSQL  (Sunil Jadhav <sunilbjpatil@gmail.com>)
List pgsql-admin
Hi,
You can try the following options
  • Edit pg_hba.conf file and change authentication method to trust
    Reload postgres iand login without password
    psql -U postgres
    And then you can use alter command
    ALTER USER your_username WITH SUPERUSER; 
  • If you have root access to the server than you can directly switch to postgres superuser
    sudo -i -u postgres
    psql
    ALTER USER your_username WITH SUPERUSER;
  • If you can't log in with sudo but have access to the PostgreSQL data directory, you can start PostgreSQL in single-user mode to reset the password
    sudo -u postgres postgres --single -D /var/lib/pgsql/data  (Change your path accordingly)
    ALTER USER postgres WITH PASSWORD 'new_password';
    Exit single user mode and start postgres normally
      

On Thu, 19 Sept 2024 at 18:31, Sunil Jadhav <sunilbjpatil@gmail.com> wrote:
Hello Team,

I have login with non super user in PostgreSQL instance.
How to become a super user
I tried and getting a below error 
 "must be  superuser to alter superuser" 
 How to resolve this?
I don't know the superuser password?

Thanks for your help in advance

Thanks
Sunil jadhav 

pgsql-admin by date:

Previous
From: Holger Jakobs
Date:
Subject: Re: How to make superuser from non superuser in PostgreSQL
Next
From: AjithKumar Kannan
Date:
Subject: Re: Postgres - SSL connection using only root CA