Re: How to make superuser from non superuser in PostgreSQL

From: Muhammad Usman Khan <usman(dot)k(at)bitnine(dot)net>
To: Sunil Jadhav <sunilbjpatil(at)gmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: How to make superuser from non superuser in PostgreSQL
Date: 2024-09-20 04:18:34
Message-ID: CAPnRvGs3f7zck7YM+efXgW0G9TrgxybouKf7XJzwkadQ7QrgDg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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(at)gmail(dot)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
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message AjithKumar Kannan 2024-09-20 11:27:05 Re: Postgres - SSL connection using only root CA
Previous Message Holger Jakobs 2024-09-19 15:50:27 Re: How to make superuser from non superuser in PostgreSQL