postgresqlpgadmin-4postgresql-11

FATAL: password authentication failed for user "postgres" (postgresql 11 with pgAdmin 4)


I recently installed Postgresql 11, during the installation, there's no step to put password and username for Postgres. Now in pgAdmin 4, I wanted to connect the database to server and it's asking me to input password, and I haven't put any in the first place.

Any one knows what's going on?


Solution

  • The default authentication mode for PostgreSQL is set to ident.

    You can access your pgpass.conf via pgAdmin -> Files -> open pgpass.conf

    enter image description here

    That will give you the path of pgpass.conf at the bottom of the window (official documentation).

    After knowing the location, you can open this file and edit it to your liking.

    If that doesn't work, you can:

    Here is an example of the pg_hba.conf file (METHOD is already set to trust):

    # TYPE  DATABASE        USER            ADDRESS                 METHOD
    
    # IPv4 local connections:
    host    all             all             127.0.0.1/32            trust
    
    # IPv6 local connections:
    host    all             all             ::1/128                 trust
    

    NOTE: Remember to change the METHOD back to md5 or other auth-methods listed here after changing your password (as stated above).