Postgresql: password authentication failed for user “postgres”

前端 未结 19 1480
时光取名叫无心
时光取名叫无心 2020-11-22 13:34

I have installed PostgreSQL 8.4, Postgres client and Pgadmin 3. Authentication failed for user \"postgres\" for both console client and Pgadmin. I have typed user as \"postg

相关标签:
19条回答
  • 2020-11-22 14:21

    If you are trying to login postgres shell as postgres user, then you can use following commands.

    switch to postgres user

    # su - postgres
    

    login to psql

    # psql
    

    Hope that helps

    0 讨论(0)
  • 2020-11-22 14:21

    I had faced similar issue. While accessing any database I was getting below prompt after updating password "password authentication failed for user “postgres”" in PGAdmin


    Solution:

    1. Shut down postgres server
    2. Re-run pgadmin
    3. pgadmin will ask for password.
    4. Please enter current password of mentioned user

    Hope it will resolve your issue

    0 讨论(0)
  • 2020-11-22 14:22

    I just wanted to add that you should also check if your password is expired.

    See Postgres password authentication fails for details.

    0 讨论(0)
  • 2020-11-22 14:23

    Here are some combinations which I tried to login:

    # login via user foo
    psql -Ufoo -h localhost
    
    sudo -u postgres psql postgres
    
    # user foo login to postgres db
    psql -Ufoo -h localhost -d postgres
    
    0 讨论(0)
  • 2020-11-22 14:24

    For those who are using it first time and have no information regarding what the password is they can follow the below steps(assuming you are on ubuntu):

    1. Open the file pg_hba.conf in /etc/postgresql/9.x/main

       sudo vi pg_hba.conf 
      

      2.edit the below line

       local   all             postgres                                peer
      

      to

       local   all             postgres                                trust
      
    2. Restart the server

        sudo service postgresql restart
      
    3. Finally you can login without need of a password as shown in the figure

    Ref here for more info

    0 讨论(0)
  • 2020-11-22 14:24

    i had a similar problem. Ubuntu was left me log in in console with any password for superuser. Except when i connected with -h localhost in psql line command.

    I Observed too that "localhost:8080/MyJSPSiteLogIn" - showed: Fatal: autentication error with user "user".

    pg_hba.conf was ok.

    I noted had two versions of postgres running in the same service.

    Solved - uninstalling inutil version.

    0 讨论(0)
提交回复
热议问题