'cannot connect to Postgres - password unknown

I can't connect on postgresql.

when i go on pgadmin>server>postgresql, it asked me "please enter the password for the user 'postgres' to connect the server?

I have windows 10 and postgresql 14.

But I don't have this password. What can I do?

enter image description here



Solution 1:[1]

This worked for me. Change METHOD of all rows in your pg_hba.conf file from scram-sha-256 to trust (C:\Program Files\PostgreSQL\14\data\pg_hba.conf). This will disable password for your DB. Click on any database in postgresql to use Query Tool.

In Query Tool type ALTER USER postgres WITH PASSWORD 'User_password'; postgres is default username, execute it. This way you can set up a password for your db, after that go back to the first step and change it back from trust to scram-sha-256.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1