PostgreSQL: password authentication failed for user “postgres” in Ubuntu

While doing your first PostgreSQL login, Have you got an error like: password authentication failed for user “postgres”.

Relax, No problem !
This is very common error for the user of Linux PostgreSQL.

Here,You can access other related and important articles.

PostgreSQL: How to Install PostgreSQL 9.4 on Ubuntu 14.04?

PostgreSQL: How to Allow Remote Connection to Connect Database

When we install PostgreSQL on Linux, by default, no any password assigns to the Postgres super user.
We should explicitly SET the postgres user password using something like below command.

Now try to connect using postgres user:

What If I forgot my Postgres user password?

If you forgot your postgres password, you can login without password by changing “md5” to “trust” in pg_hba.conf file and restart the PostgreSQL server.
After login, you can ALTER postgres user:

Now again change your pg_hba.conf entry from “trust” to “md5” and restart the PostgreSQL server.

Anvesh Patel

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz