How to pg_dumpall without root password

Started by Dat Chualmost 19 years ago4 messagesgeneral
Jump to latest
#1Dat Chu
dattanchu@gmail.com

Hi,

I am the new sysadmin and was given the task to move a postgresql
installation from one box to another. So I want to do pg_dumpall .

However, there is no record of postgresql superuser/root password. I
do have root access to the system however.

Does anyone have a suggestion on what I should do?

#2Hannes Dorbath
light@theendofthetunnel.de
In reply to: Dat Chu (#1)
Re: How to pg_dumpall without root password

On 11.07.2007 08:10, Dat Chu wrote:

I am the new sysadmin and was given the task to move a postgresql
installation from one box to another. So I want to do pg_dumpall .

However, there is no record of postgresql superuser/root password. I
do have root access to the system however.

Does anyone have a suggestion on what I should do?

Locate pg_hba.conf (should reside in $PGDATA), open it in an editor,
replace md5 with trust.

--
Regards,
Hannes Dorbath

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Dat Chu (#1)
Re: How to pg_dumpall without root password

Dat Chu <dattanchu@gmail.com> writes:

I am the new sysadmin and was given the task to move a postgresql
installation from one box to another. So I want to do pg_dumpall .

However, there is no record of postgresql superuser/root password. I
do have root access to the system however.

Edit pg_hba.conf to allow local "trust" access. SIGHUP or restart
postmaster. Connect as postgres user and set password as you see fit.
Restore the previous pg_hba.conf settings (and SIGHUP again).

If you're worried about having the system insecure even transiently
against local bad guys, it's possible to do this without opening any
hole, but it requires taking the DB down for a few minutes so you can
do the password change in standalone mode.

regards, tom lane

#4Stephen Frost
sfrost@snowman.net
In reply to: Tom Lane (#3)
Re: How to pg_dumpall without root password

* Tom Lane (tgl@sss.pgh.pa.us) wrote:

If you're worried about having the system insecure even transiently
against local bad guys, it's possible to do this without opening any
hole, but it requires taking the DB down for a few minutes so you can
do the password change in standalone mode.

An alternative to 'trust' might be to change pg_hba.conf to use 'ident'
over a local socket (on systems which support that). You'd need to know
the superuser name (usually 'postgres') and either become that user on
the unix side or set up an ident map from whatever user you want to
be...

Thanks,

Stephen