For When You Can't Have The Real Thing
[ start | index | login ]
start > postgresql > change root password

change root password

Created by dave. Last edited by dave, 13 years and 303 days ago. Viewed 5,262 times. #2
[diff] [history] [edit] [rdf]

Change Root Password

...if you don't know it.

The "root" or superuser for postgresql is the user that the server runs as. To set this password if it is unset:

$ psql -U postgres -d template1
template1=# alter user postgres with encrypted password 'yourpassword';
template1=# q

If the password is already set, you can't run psql. To temporarily grant password-less access:

Add this line in pg_hba.conf (for v7):

local all all trust

...for v8:

local all postgres trust

...then restart postgres. Then run the psql line above. Then remove the line from pg_hba.conf, and restart postgres again.

no comments | post comment
This is a collection of techical information, much of it learned the hard way. Consider it a lab book or a /info directory. I doubt much of it will be of use to anyone else.

Useful: | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt