Reset postgres user password in PostgreSQL Ubuntu 11.10 Oneiric is very simple. First, make sure you have set trust mode in pg_hba.conf ( /etc/postgresql/9.1/main/pg_hba.conf ), for instance :
1 2 3 4 5 6 | local all postgres trust # TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all trust |
Then restart postgreql service by :
1 | sudo service postgresql restart |
Now, you can use sudo to login into postgres user :
1 | psql -U postgres |
Or if you want to login into postgres account and change it directly from this user :
1 2 | sudo su postgres psql |
Then, run postgres CHANGE PASSWORD :
1 | postgres=# ALTER USER postgres WITH PASSWORD ‘<your-new-password>’; |
Done! Now you can login into postgres user with new password. Don’t forget to set another user authentication in pg_hba.conf with “md5” method.