9

I'm using PostgreSQL for the first time and I am not familiar with it. When I start pgadmin and enter master password and when I want to connect to postresql and again enter same password following error pops up:

could not connect to server: could not initiate GSSAPI security context: The operation or option is not available could not initiate GSSAPI security context: Credential for asked mech-type mech not found in the credential handle FATAL: password authentication failed for user "postgres"

Whats the problem here?

3
  • Apparently your installation is configured to use GSSAPI (e.g. LDAP or Active Directory) you will need to ask whoever installed that what the account's password is. Commented May 25, 2020 at 12:47
  • Thank very much. I've installed the Postgres 13 beta version. tried also the postgres 12, always the same. I also always used the same password. is there a possibility to configure installation without gssapi? Commented May 25, 2020 at 12:49
  • Yes, just remove it from pg_hba.conf Commented May 25, 2020 at 12:50

3 Answers 3

14

I just had the same issue and below is how I solved it. Because you don't have a default password for the user 'postgres', you will need to set one first, like this :

  1. Connect to the terminal as the user 'postgres' with the current admin credential (thanks sudo)

    sudo -u postgres -i
    
  2. Connect to the database 'postgres'

    psql postgres
    
  3. (optional) If the psql command is not found, you can the PostgreSQL bin path to your $PATH like this :

    export PATH=$PATH:THE_PATH_TO_POSTGRESQL_BIN_FOLDER
    # Example : export PATH=$PATH:/Library/PostgreSQL/12/bin
    
  4. Change the password of the user 'postgres'

    --- Do not forget to my_password with the desired password
    ALTER USER postgres PASSWORD 'my_password';
    

In the pgAdmin windows, try to connect with this new password, it should work.

Sign up to request clarification or add additional context in comments.

2 Comments

command 'psql postgres' requires the password for postgres user, so this solution does not fix the authentication issue for postgres user.
The command 'sudo -u postgres -i' helps you with that. The password asked is the connected user's one (if it have the sudo rights).
0

It is ridiculous but my solution after many trial was very very simple.

Problem seems that password is not match or connection problem. So, first make sure your password is definitely correct. You might think you enter exact same but it might be not. I tried to wrote a password to somewhere else that i can see it is correct.Then, i copied that and paste it to setup where you put your new password. Ofcourse you have to remove postgre completely for this to try.

When setup is completed, if you tried and didn't work again, then delete Postgre server and create new one. Just enter server name, connection address and password and save. if this one also not work successfully,maybe you should check if the chosen port number is alive or not for postgre server.

Sorry for that answer is not visual and some english mistakes. I just wanted to wrote really fast. Good luck :)

1 Comment

When i meant you make sure your password is correct, i am pretty sure yours correct but i don't why it doesn't match when i wrote by hand. but if you copy paste from somewhere else then it is correct. Some Mac os problems or maybe language and keyboard problem
0

I'm not sure if you're using nest but I was having the same issue because AWS RDS requires SSL by default. I fixed the issue for me by adding the following in my app.module.ts

    ssl: {
      rejectUnauthorized: false,
    },

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.