6

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?

  • 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. –  May 25 '20 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? – Severin Stillhard May 25 '20 at 12:49
  • Yes, just remove it from [pg_hba.conf](https://www.postgresql.org/docs/current/auth-pg-hba-conf.html) –  May 25 '20 at 12:50

2 Answers2

12

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.

erde
  • 121
  • 1
  • 6
  • command 'psql postgres' requires the password for postgres user, so this solution does not fix the authentication issue for postgres user. – jonah butler May 23 '23 at 14:19
  • 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). – erde May 25 '23 at 08:39
1

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 :)

Ahmet
  • 21
  • 1
  • 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 – Ahmet Nov 30 '22 at 12:52