Database Research & Development

  • Home
  • NoSQL
    • NoSQL
    • Cassandra
  • Databases
    • Database Theory
    • Database Designing
    • SQL Server Coding Standards
    • SQL Server
    • PostgreSQL
    • MySQL
    • Greenplum
    • Linux
  • Interviews
    • SQL Server Interviews
    • MySQL Interviews
    • SQL Puzzles
  • DBA Scripts
    • SQL Server DBA Scripts
    • PostgreSQL DBA Scripts
    • MySQL DBA Scripts
    • Greenplum DBA Scripts
  • Home
  • Blog Archives !
  • (: Laugh@dbrnd :)
  • Contact Me !
sqlserverinterviews
Home 2016 August PostgreSQL: password authentication failed for user “postgres” in Ubuntu

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

This article is half-done without your Comment! *** Please share your thoughts via Comment ***

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.

1
2
3
4
ubuntu@:~$ sudo passwd postgres
Enter new UNIX password:****
Retype new UNIX password:****
passwd: password updated successfully

Now try to connect using postgres user:

1
2
ubuntu@:~$ su postgres
Password:****

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:

1
ALTER USER postgres PASSWORD 'MyNewPassword';

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

Aug 24, 2016Anvesh Patel
PostgreSQL: Example of Trigram Index for Full Text Search using pg_trgm ExtensionPostgreSQL: Optimized way to get first Record per each GROUP (using DISTINCT ON, LATERAL)
Comments: 8
  1. Srini
    October 9, 2018 at 7:02 am

    Thanks for the post Anvesh, It saved my day and pretty much helped to resolve my issue.

  2. thankfull_individual
    June 29, 2019 at 12:36 pm

    thank you for not telling us where the file pg_hba.conf is thanks again

  3. Bharath
    January 21, 2020 at 11:24 am

    i hope reload will work instead of restarting the service for config changes to take place

  4. Binu
    February 2, 2020 at 6:15 pm

    It worked for me. Thanks

  5. Cucumberisgood
    April 7, 2020 at 9:00 am

    thanks bro,it works pretty well 🙂 nicee solution

    • Anvesh Patel
      Anvesh Patel
      May 27, 2020 at 12:14 pm

      Great…

  6. Embiel Cardenas
    April 22, 2020 at 12:28 pm

    thanks, dude.Very helpful than those stack overflow threads

    • Anvesh Patel
      Anvesh Patel
      May 27, 2020 at 12:12 pm

      great thanks

Anvesh Patel
Anvesh Patel

Database Engineer

August 24, 2016 PostgreSQLAnvesh Patel, authentication, database, database research and development, dbrnd, forget postgres password, invalid user, plpgsql, Postgres Query, postgres super user, postgresql, PostgreSQL Administrator, PostgreSQL Error, PostgreSQL Programming, PostgreSQL Tips and Tricks, reset postgres password
About Me!

I'm Anvesh Patel, a Database Engineer certified by Oracle and IBM. I'm working as a Database Architect, Database Optimizer, Database Administrator, Database Developer. Providing the best articles and solutions for different problems in the best manner through my blogs is my passion. I have more than six years of experience with various RDBMS products like MSSQL Server, PostgreSQL, MySQL, Greenplum and currently learning and doing research on BIGData and NoSQL technology. -- Hyderabad, India.

About DBRND !

dbrnd

This is a personal blog (www.dbrnd.com).

Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated.

Feel free to challenge me, disagree with me, or tell me I’m completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or anonymous comments) - so keep it polite.

The content of this website is protected by copyright. No portion of this website may be copied or replicated in any form without the written consent of the website owner.

Recent Comments !
  • Anvesh Patel { Sure will do... } – May 27, 12:43 PM
  • Anvesh Patel { Great... } – May 27, 12:41 PM
  • Anvesh Patel { Great... } – May 27, 12:39 PM
  • Anvesh Patel { Great... } – May 27, 12:36 PM
  • Anvesh Patel { Great... } – May 27, 12:28 PM
  • Anvesh Patel { Great... } – May 27, 12:27 PM
  • Anvesh Patel { Great... } – May 27, 12:16 PM
  • Older »
Follow Me !
  • facebook
  • linkedin
  • twitter
  • youtube
  • google
  • flickr
© 2015 – 2019 All rights reserved. Database Research & Development (dbrnd.com)
Posting....