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.

Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

If you like this post, then please share it with others.
Please follow, I will share my experience towards the success of Database Research and Development Activity.

I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.

More from

Leave a Reply

Be the First to Comment!

Notify of