public inbox for [email protected]  
help / color / mirror / Atom feed
From: Muhammad Usman Khan <[email protected]>
To: Sunil Jadhav <[email protected]>
Cc: [email protected]
Subject: Re: How to make superuser from non superuser in PostgreSQL
Date: Fri, 20 Sep 2024 09:18:34 +0500
Message-ID: <CAPnRvGs3f7zck7YM+efXgW0G9TrgxybouKf7XJzwkadQ7QrgDg@mail.gmail.com> (raw)
In-Reply-To: <CAEQOu1F5NDuv556QtNyqFEPyu4r+3SJAeTsSwGDU6_ECCEDxOA@mail.gmail.com>
References: <CAEQOu1F5NDuv556QtNyqFEPyu4r+3SJAeTsSwGDU6_ECCEDxOA@mail.gmail.com>

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 <[email protected]> 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
>


view thread (4+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: How to make superuser from non superuser in PostgreSQL
  In-Reply-To: <CAPnRvGs3f7zck7YM+efXgW0G9TrgxybouKf7XJzwkadQ7QrgDg@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox