Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

psql: error: could not connect to server: FATAL: password authentication failed for user

I have successfully installed postgresql and added path to my environment variable in windows 10. But the problem is when i try to run psql postgresql in command prompt it gives error saying

C:\Users\adity>psql postgres
Password for user adity:
psql: error: could not connect to server: FATAL:  password authentication failed for user "adity"

I am 100% sure my password is correct I have tried reinstalling and uninstalling many time in case i missed password but every time it gives me same error. Although when i try to run from GUI it starts running. This is frustrating and I am not sure what the problem is.

like image 774
aditya kumar Avatar asked Dec 06 '19 09:12

aditya kumar


People also ask

How to resolve PSQL fatal peer authentication failed for user “Postgres” error?

How To Resolve Psql: Fatal: Peer Authentication Failed For User “postgres” Error When Login Postgresql In Command Line 1 Postgresql Authentication Methods.#N#Peer Authentication : This authentication method will use the base operating... 2 How To Change Postgresql Authentication Method. More ...

Could not connect to Server PostgreSQL?

psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket “/tmp/.s.PGSQL.5432”? Incorrect authentication method ( ident) configured on PostgreSQL. Connect to the server via SSH.

What is peer authentication in PostgreSQL?

Peer Authentication : This authentication method will use the base operating system’s user name and password as the postgresql database server user account to login, this method is only effetive for local postgresql connection.

How to configure incorrect authentication method on PostgreSQL?

Incorrect authentication method ( ident) configured on PostgreSQL. Connect to the server via SSH. Edit file /var/lib/pgsql/data/pg_hba.conf, replacing ident to trust in the section beginning with “local”, as follows:


1 Answers

The database superuser that was created during database cluster creation is very likely called postgres.

So rather than using the default, which is to use the database user whose name is the same as your current operating system user, explicitly specify the database user postgres:

psql -U postgres
like image 174
Laurenz Albe Avatar answered Sep 23 '22 07:09

Laurenz Albe