Re: Lost password to user postgres - Mailing list pgsql-admin

From Andy Shellam (Mailing Lists)
Subject Re: Lost password to user postgres
Date
Msg-id 4572B52A.40600@mailnetwork.co.uk
Whole thread Raw
In response to Re: Lost password to user postgres  (Scott Marlowe <smarlowe@g2switchworks.com>)
List pgsql-admin
Regarding point 1, Scott, the user is on Windows.

Windows binaries are available at www.postgresql.org and a lot has
changed in the last 2 years, so if you do go down the re-install route,
I'd recommend upgrading, although you'll have to dump your old data out
of the server first, then restore it in to the new version.

Regarding passwords, are you talking about the service account for the
PostgreSQL database, or the postgres user in the database server?
You can change the service account using the "Local Users & Groups"
control panel (run "lusrmgr.msc") but you'll also need to change the
logon user in the Services control panel for the PostgreSQL Database
Server service.

If you're talking about the postgres user, edit your pg_hba.conf file
(Start > Programs > PostgreSQL [version] > Edit pg_hba.conf (or
there-abouts.)
Add (or change if it already exists) a line (if it doesn't exist, add it
before any other "host...." lines)

host   all   all   127.0.0.1/32   trust

And restart the PostgreSQL service.
Then when you connect to 'localhost', you'll always be granted access.
Login, change the postgres user password, then edit your pg_hba.conf
file again, to:

host   all   all   127.0.0.1/32   md5

And restart the service, then you should be able to login with that
password.

Andy.

Scott Marlowe wrote:
> On Sat, 2006-12-02 at 11:44 -0800, Philippe Salama wrote:
>
>> 2 years ago, I installed postgresql on my desktop and used it for a
>> while for learning purposes.  Then, I stopped using it.  I forgot the
>> password to the user postgres
>>
>
> You don't have to reinstall.  you've got three basic options:
>
> 1. Change the password in single user mode
> 2. Edit pg_hba.conf and set it to trust mode, change your password,
> change back to md5
> 3. Re-initdb your cluster.
>
> For 1:
> su - postgres (from root if you have to)
> pg_ctl stop
> postgres template1 (or some other database you know exists)
> alter user postgres password 'newpassword';
>
> For 2:
> su - postgres
> cd $PGDATA
> vi pg_hba.conf
> // change entries at bottom to trust
> pg_ctl reload
> psql template1
> alter user postgres password 'newpassword';
>
> For 3:
> su - postgres
> pg_ctl stop
> echo $PGDATA  // make sure this is set to something like /var/lib/pgsql
> rm -rf $PGDATA/*
> initdb // with whatever options you need.
>
> I prefer option 2, as you don't have to take down your database to do
> it.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>                http://archives.postgresql.org
>
> !DSPAM:37,45720b9840411059761709!
>
>
>


--
Andy Shellam
NetServe Support Team

the Mail Network
"an alternative in a standardised world"

p: +44 (0) 121 288 0832/0839
m: +44 (0) 7818 000834


pgsql-admin by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: Settings for writing!
Next
From: "Doron Baranes"
Date:
Subject: insert and returning