DBA Hub

📋Steps in this guide1/1

Set password to original one without knowing

--- Lets say you forgot the password of the user and u want to set the same password to that user in same or different db

postgresql configurationintermediate
by PostgreSQL
15 views
1

Set password to original one without knowing

1. Set a password for the user dbaprod postgres=# alter user dbaprod password 'old'; ALTER ROLE postgres=# 2.Note down the encrypted password postgres=# SELECT rolname, rolpassword FROM pg_catalog.pg_authid where rolname='dbaprod'; rolname | rolpassword ---------+------------------------------------- dbaprod | md5bbb103edd695a83d45db75755e459a78 -- > NOTE DOWN THIS ONE (1 row) 3. Change the password and check the encrypted password 4.Now update this rolpassword with the value we got at step 2 Now try to connect to the database using the first password 'old'

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
--- Lets say you forgot the password of the user and u want to set the same password to that user in same or different db
postgres=#
alter user dbaprod password 'new';
ALTER ROLE
postgres=#
SELECT rolname, rolpassword FROM pg_catalog.pg_authid where rolname='dbaprod';
rolname | rolpassword
---------+-------------------------------------
dbaprod | md5041382740aeba232404af81454f48d7f ( it has been changed)
postgres=#
update pg_catalog.pg_authid set rolpassword = 'md5bbb103edd695a83d45db75755e459a78' where rolname='dbaprod';
UPDATE 1
postgres$
PGPASSWORD=old
./psql -d postgres -U dbaprod
Password:
psql (12.3)
Type "help" for help.

Comments (0)

Please to add comments

No comments yet. Be the first to comment!