Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

psql: FATAL: password authentication failed for user windows 8

I installed postgresql on windows and while the installation it asks to make a user for the account.This made a new windows user in my computer called postgres, I have created a password for it as well.

Now I want to run psql on windows command line, it asks for a password (without mentioning the user) and always gives me back the error: psql: FATAL: password authentication failed for user "Ash". Even though I have put my accounts password many times.

using pgadmin I changed the user "postgres" to "Ash" but I have yet to remake the password. I followed the steps here: I forgot the password I entered during postgres installation (I rather types host all 127.0.0.1/32 trust because I am on windows), but when running psql again so that I can change the password I get the error: psql FATAL:could not load pg_hba.conf. All together.

Why can it not load? All I did was add an extra authentication option.

Also, is the windows user separated from a postresql user or are they the same(depend on each other)?

Edit:

As you can see, it did not give me the option to choose if Aisha should be a superuser or not. or the other options for that matter.

I also used pgadmin||| to create a new user but the same error pops up: enter image description hereenter image description here

The user does not exist so why does it do this?

like image 930
Sarah cartenz Avatar asked Jun 24 '15 13:06

Sarah cartenz


People also ask

How do I fix postgres password authentication failed?

Restart the PostgreSQL service from the Services control panel ( start->run->services. msc ) Connect using psql or pgAdmin4 or whatever you prefer. Run ALTER USER postgres PASSWORD 'fooBarEatsBarFoodBareFoot'

What is the password for user postgres Windows?

By Default, the user is 'postgres' and the password is the one which you enter while installing the database.

How do I enable postgres authentication?

To authenticate network connections from the PostgreSQL server's machine (non-socket connections) using passwords, you need to match a host connection type instead of local . You can then limit the acceptable addresses to the local loopback devices and allow users to authenticate using md5 or scram-sha-256 .

What is the default postgres password?

1, the default Postgres database password is postgres . Type the new password for the selected user type. Type the password again to confirm it. Click Save Configuration.


1 Answers

The user on your machine has nothing to do with the user on PostgreSQL. The installer just creates an account and a PostgreSQL role with the same name and password (which in my mind is a bad idea), but they're not related in any way. The Windows user is used to run the server, the PostgreSQL role is used inside the database.

So you should first access the server with the user postgres and then create a user for yourself. Don't change the username inside the server, or the server's running user! Just create a new username and grant it the permissions you need.

You can use psql -U postgres to connect to the server and it'll ask for the password.

Check the permissions for pg_hba.conf, the postgres user must have permissions for it. If you only edited it as an admin, it should be ok, but if you took permissions or anything else, it may mess it up.

like image 126
Sami Kuhmonen Avatar answered Oct 16 '22 16:10

Sami Kuhmonen