Re: Reset Postgresql users password - Mailing list pgsql-general

From Chris Travers
Subject Re: Reset Postgresql users password
Date
Msg-id CAKt_Zft9gjbQB003MgMSHR3-JXei2ccvMB+BRuK6KUXUhPLR+Q@mail.gmail.com
Whole thread Raw
In response to Re: Reset Postgresql users password  (Ron <ronljohnsonjr@gmail.com>)
List pgsql-general
You can use a DO block or write a function do to this.

It takes some practice (and you need to use EXECUTE FORMAT())

If users need to be able to change their own users, something like this works:

CREATE FUNCTION change_my_password(in_password, text)
returns void language plpgsql as
$$
begin
   EXECUTE FORMAT($F$ALTER USER $I WITH PASSWORD %L$F$, session_user, in_password);
end;
$$ SECURITY DEFINER;

On Mon, Jul 17, 2023 at 9:28 AM Ron <ronljohnsonjr@gmail.com> wrote:
On 7/12/23 14:28, Johnathan Tiamoh wrote:
> Hello,
>
> I wish to find out if there is a way to reset all users in Postgresql
> password to the same password at once.

To the same value??

--
Born in Arizona, moved to Babylonia.




--
Best Wishes,
Chris Travers

Efficito:  Hosted Accounting and ERP.  Robust and Flexible.  No vendor lock-in.

pgsql-general by date:

Previous
From: Bogdan Siara
Date:
Subject: Postgrsql blocked for more than 120 s
Next
From: basti
Date:
Subject: Query take a long time and use no index