Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

When I set the password to blank, it didn't give any warnings. Now when I try to log in with a blank password, it gives me an error "fe_sendauth: no password supplied". So now I can't log in - any ideas how I can get access to the db again?

share|improve this question

migrated from stackoverflow.com Feb 7 '13 at 15:51

This question came from our site for professional and enthusiast programmers.

2 Answers 2

This blogpost should answer. Full disclosure: it's my blogpost.

Summary:

If you have access to shell account on the machine PostgreSQL is running, and your shell works as the same user as Postgres itself, or root – solution is easy.

Edit your pg_hba.conf file, and at the beginning of it put:

local all all trust

or (depending on your paranoia):

local all postgres ident

And restart your PostgreSQL (usually something like /etc/init.d/postgres restart).

Afterwards you should be able to connect to Postgres as postgres user without password.

You should note, that if you have choosen the option with “ident” you will be able to connect without password only from shell account named “postgres”.

don't forget to reverse the pg_hba.conf settings when you have reset the password.

share|improve this answer
    
Sorry for the fuss depesz, I hope you don't mind my summary of your blog post. You are a special user and deserve special treatment but some from outside the postgres world on this site don't know that :) –  Jack Douglas Feb 8 '13 at 12:38
2  
No problem at all. I definitely do not feel special, I'm just not in favor of adding yet-another (after all google/bing/whatever caches) copy of the same information. But if someone (like you in this case) wants to add it - I have no problem with it. –  user1593 Feb 8 '13 at 13:13
up vote 1 down vote accepted

It really depends on how your cluster is configured...

If you have another administrator user (postgres?) you can just connect and:

ALTER USER username PASSWORD 'new password';

Otherwise you could (temporarily) allow password-less logins in pg_hba.conf (see http://www.postgresql.org/docs/9.2/static/auth-pg-hba-conf.html - search for the word "trust")

share|improve this answer
1  
I just edited giorgiga's post to remove UNENCRYPTED. There is an obvious confusion here, that folks might think it refers to the password supplied in the argument, but in fact it refers to storage. I seem to recall a few very unusual corner cases where it might be appropriate but it is definitely not a good blanket recommendation unless you know very clearly that you need it and why. –  Chris Travers Feb 8 '13 at 12:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.