Re: Reset Postgresql users password

From: Johnathan Tiamoh <johnathantiamoh(at)gmail(dot)com>
To: Gurjeet Singh <gurjeet(at)singh(dot)im>
Cc: Gianni Ceccarelli <dakkar(at)thenautilus(dot)net>, Mateusz Henicz <mateuszhenicz(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Reset Postgresql users password
Date: 2023-07-12 20:25:11
Message-ID: CACoPQdasnttEJ_amDnj02qu=e9i_bP80OWKG-+ihro+e2AucaQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thank you all very much.

I really appreciate !!

On Wed, Jul 12, 2023 at 4:17 PM Gurjeet Singh <gurjeet(at)singh(dot)im> wrote:

> On Wed, Jul 12, 2023 at 12:42 PM Mateusz Henicz <mateuszhenicz(at)gmail(dot)com>
> wrote:
> >
> > You can also just write an sql and execute it, like:
> >
> > select 'alter user '|| usename ||' with password ''newpassword'';' from
> pg_user;
> > \gexec
>
> Note that the above assumes you're using psql.
>
> For tools other than psql, you'd have to use dynamic SQL something
> like the DO block below. It will work on psql, just as well.
>
> DO $$
> declare
> rec record;
> begin
> for rec in select
> 'alter user '|| quote_ident(usename)
> ||' with password '|| quote_literal('newpassword')
> as c from pg_user
> loop
> raise notice 'Executing command: %', rec.c;
> execute rec.c;
> end loop;
> end;
> $$;
>
> Best regards,
> Gurjeet
> http://Gurje.et
>
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2023-07-12 20:35:42 Re: Reset Postgresql users password
Previous Message Gurjeet Singh 2023-07-12 20:16:53 Re: Reset Postgresql users password