Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1srV6g-0029Lw-FV for pgsql-admin@arkaria.postgresql.org; Fri, 20 Sep 2024 04:18:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1srV6e-00ELNR-3P for pgsql-admin@arkaria.postgresql.org; Fri, 20 Sep 2024 04:18:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1srV6d-00ELNI-KO for pgsql-admin@lists.postgresql.org; Fri, 20 Sep 2024 04:18:57 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1srV6Z-0007iO-OD for pgsql-admin@postgresql.org; Fri, 20 Sep 2024 04:18:55 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-206e614953aso17348345ad.1 for ; Thu, 19 Sep 2024 21:18:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bitnine-net.20230601.gappssmtp.com; s=20230601; t=1726805930; x=1727410730; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=7If/NhQ++KusmwznG+l5Mh/ASqncBa7PfZEqGeWGzII=; b=WKi66i7lsHUt8O6qXq3cgOLkqIqgIt4hMh4jCYDdXECHIikI9IHofF1sGUj7XqnhCH Y+Jur0dw6UyYPDdfePSPC4ZT+O6sV8GPkYQb5wsEZPvbUjzmGXBMW+4w1kSjo+ADg9FB b7jsK3DGhxsIHy4maxPSwUboy7lrj7UKaNb2/fU4PW3LcgA84OJnNYF8FwGa9uvnqpGH gIl0w1p/1r7ZG/veHa8ijSE0geR36Fmm9PBYyV50juS/4lm3vvezItFrdOCWIp0zyggA MHjJjd6Vob9rauTndRgfuou7KohZecmAdyQrDlAjD7S0r6xxB8ZA65wH5UDMp/OXVx4o Fxww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726805930; x=1727410730; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7If/NhQ++KusmwznG+l5Mh/ASqncBa7PfZEqGeWGzII=; b=thW1T90oanOFBSu81z+ifg/HV2db5/NVrGItA6JcjzxAPXKFCXaLjyR4LBnaZaGHaF 9w7wRin9avrP90jh77lWbOFtoD9bXBcjfLnpBri6216/luNKIOyvJwIxKX6ks5SJi1xs F574jkqRJ/PZuFg5mpDGbOqPUc5P+VFAFNPCmZdAyIBgn9uJEqkgU8b+xJ6kgcmCeKmf w9sDk6mtKnZpn3fNNNqpk1pr1MDi+Pj0JPZ0gXhHR3Hkz+SL9iJQivFvX6yk+HoLEHoH KsHX162qP3smWO+axV1QHIVRQQpIpzdYek7ubfv7w62UEfO77o3SDAHN1YECWyPlsPZ0 QRfA== X-Gm-Message-State: AOJu0YxYh8n6cVjHT5aL1gBy/g8CAE1HQZfJ0XoJsvI71OLm7tTPRimy PqQquzvX21In/hCW2tEeXvmjHoIy52xyemN/OpDadgi8J0sLcfasnIPouRN4MrIil6FASCZuFkS ANZ32zGmn2ML4CwbJO/FrwscZTmA3w672x/ZwbA== X-Google-Smtp-Source: AGHT+IEAI13X/0Bvpgrq02UF8Q3zUCakDFB5hOs5kavEqnKIO+DCIaOvPM6yoQD1uzya5HSYtFMVcLieDv3gQnEiDbA= X-Received: by 2002:a17:902:d4c3:b0:205:913b:d9ad with SMTP id d9443c01a7336-208d80c831cmr25327755ad.0.1726805930444; Thu, 19 Sep 2024 21:18:50 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Muhammad Usman Khan Date: Fri, 20 Sep 2024 09:18:34 +0500 Message-ID: Subject: Re: How to make superuser from non superuser in PostgreSQL To: Sunil Jadhav Cc: pgsql-admin@postgresql.org Content-Type: multipart/alternative; boundary="00000000000014a67106228556c2" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000014a67106228556c2 Content-Type: text/plain; charset="UTF-8" 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 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 > --00000000000014a67106228556c2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,
You can try the follo= wing options
  • Edit pg_hba.conf file and change authentication met= hod to trust
    Reload postgres iand login without password
    psql -U post= gres
    And then you can use alter command
    ALTER USER your_user= name WITH SUPERUSER;=C2=A0
  • If you have root access to the server than you can directly switch to pos= tgres 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 c= an start PostgreSQL in single-user mode to reset the password
    sudo -u po= stgres postgres --single -D /var/lib/pgsql/data=C2=A0 (Change your path acc= ordingly)
    ALTER USER postgres WITH PASSWORD 'new_password';
    E= xit single user mode and start postgres normally
    =C2=A0=C2=A0

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

I have logi= n with non super user in PostgreSQL instance.
How to= become a super user
I tried and getting a below err= or=C2=A0
=C2=A0"must be=C2=A0 superuser to alte= r superuser"=C2=A0
=C2=A0How to resolve=C2=A0th= is?
I don't know the superuser password?

Thanks for=C2=A0your help in ad= vance

Thanks
Sunil jadhav=C2=A0
--00000000000014a67106228556c2--