问题
I recently installed Postgresql 11, during the installation, there's no step to put password and username for Postgres. Now in pgAdmin 4, I wanted to connect the database to server and it's asking me to input password, and I haven't put any in the first place. Any one knows what's going on. Thank you!
回答1:
You could access your pgpass.conf via pgAdmin -> Files -> open pgpass.conf
That will give you the path of pgpass.conf
at the bottom of the window (official documentation).
If you then open this file and edit it to your liking.
If that doesn't work, you can:
- Find your pg_hba.conf, usually in C:\Program Files\PostgreSQL\9.1\data\pg_hba.conf
- If necessary, set the permissions on it so that you can modify it; your user account might not be able to do so until you use the security tab in the properties dialog to give yourself that right by using an admin override.
- Alternately, find notepad / notepad++ in your start menu, right click, choose "Run as administrator", then use File->Open to open pg_hba.conf that way.
- Edit it to set the "host" line for user "postgres" on host "127.0.0.1/32" to "trust". You can add the line if it isn't there; just insert:
host all postgres 127.0.0.1/32 trust
before any other lines. (You can ignore comments, lines beginning with #).
Restart the PostgreSQL service from the Services control panel (start->run->services.msc)
connect using psql or pgAdmin4 or whatever you prefer
- and run
ALTER USER postgres PASSWORD 'fooBarEatsBarFoodBareFoot'
- remove the line you added to pg_hba.conf or change it back
- restart PostgreSQL again.
回答2:
Follow below stepsif you are using pgAdmin4 and facing error in updating password :
1] Open file "pg_hba.conf" and find "IPv4 local connections"
2] See the value under "Method" column, it must be set to "md5" becase you selected it while installing.
3] Make "md5" value blank and save the file. Restart pgAdmin4 application.
4] Now again set the value back to "md5" and input your password in pgAdmin application.
You should be successfully able to do it.
回答3:
I know this is an old question, but I had the same problem, e.g. no dialog for setting password for Postgres during installation with Postgresql 11.
Instead of doing all the file manipulations suggested in the other answers, I deleted Postgresql 11 and installed Postgresql 12, where I was prompted for setting password during installation.
来源:https://stackoverflow.com/questions/55038942/fatal-password-authentication-failed-for-user-postgres-postgresql-11-with-pg