After installing postgres, I tried to start psql on my VPS and got an authentication failure
~$ psql
Password:
psql: FATAL: password authentication failed for user "michael"
I went back to my install instructions, which had me set my password this way
sudo -u postgres psql template1
ALTER USER postgres with encrypted password 'your_password';
I tried to do that again but wasn't able to login:
sudo -u postgres psql template1
Password:
psql: FATAL: password authentication failed for user "postgres"
I'm thinking that I either forgot the password, or, more likely, did this step wrong. The instructions told me, in sudo nano /etc/postgresql/9.1/main/pg_hba.conf, to change
local all postgres
to
local all postgres md5
so in the following code, I replaced both instances of peer
with md5
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
Is there a way that I can recover or change my password now that I'm locked out?
Update
when trying to login, authentication fails whether I use user postgres or michael
sudo -u michael psql template
Password:
psql: FATAL: password authentication failed for user "michael"
/usr/share/doc/postgres*/README.Debian*
where all the install-specific details are recorded. Yes, that could be more obvious, but ... suggestions on how we can make it more obvious given that the PostgreSQL team don't control how Ubuntu package PostgreSQL?