Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fatal: password authentication failed for user "postgres" macos

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?

like image 613
Severin Stillhard Avatar asked May 16 '26 12:05

Severin Stillhard


1 Answers

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.

like image 145
erde Avatar answered May 19 '26 04:05

erde



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!