1

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

dataS
  • 35
  • 1
  • 5
  • You specified that password when you created the database user. Or if you trying to connect as the superuser, then you specified the password when you installed Postgres. –  Jan 14 '22 at 14:26
  • That's the point. I don't specify any password when i installed postgre. – dataS Jan 14 '22 at 14:32
  • You can visit this link for solution [https://stackoverflow.com/questions/64198359/pg-admin-4-password-for-postgres-user-when-trying-to-connect-to-postgresql-1](https://stackoverflow.com/questions/64198359/pg-admin-4-password-for-postgres-user-when-trying-to-connect-to-postgresql-1) – Chetan Jan 14 '22 at 17:31

1 Answers1

3

The following 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.

greybeard
  • 2,249
  • 8
  • 30
  • 66