Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pg Admin 4 - password for "postgres" user when trying to connect to PostgreSQL 13 server

I know that this question has been asked other times but I didn't find a solution to this problem!

I downloaded PostgreSQL 13 with pg Admin 4 and when I open it for the first time after installation it asks me for the master password that I was asked to set during installation, after I give the master password and this gets accepted I try to connect to the default server created during the installation: "PostgreSQL 13".

At this point, it asks me for a password for the user "postgres" that I don't know where to find. Specifically, it says: Please enter the password for the user 'postgres' to connect the server - "PostgreSQL 13".

I've already tried all the "default" passwords I managed to find on the internet but the error is always the same:

FATAL: password authentication failed for user "postgres"

I've also tried not to insert any password with the resulting error:

fe_sendauth: no password supplied

I don't know what to do. In PostgreSQL 13 the authentication method is encrypted via scram-sha-256. I already tried to set the method to trust, restart the mac, and open pg Admin 4 that keeps asking me for the password to access the server.

I've also tried to use the command line tool but end up encountering the same errors.

Finally, this is how my pg_hba.conf looks like:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     scram-sha-256
# IPv4 local connections:
host    all             all             127.0.0.1/32            scram-sha-256
# IPv6 local connections:
host    all             all             ::1/128                 scram-sha-256
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     scram-sha-256
host    replication     all             127.0.0.1/32            scram-sha-256
host    replication     all             ::1/128                 scram-sha-256

PS. I've also tried to uninstall PostgreSQL 13, deleting the postgres user and re-download and re-install everything... nothing changed.


If someone could help me would become my savior, thanks beforehand!

like image 200
Masso Avatar asked Oct 04 '20 18:10

Masso


People also ask

What is the default password for PostgreSQL 13?

Login and Connect as Default User For most systems, the default Postgres user is postgres and a password is not required for authentication.

What is the default password for pgAdmin4?

By Default, the user is 'postgres' and the password is the one which you enter while installing the database. (Version 11,12 I have tested). and enter the password used while installing. Or create a user with login permissions using PgAdmin tool.

What is my pgAdmin username and password?

Run the query from pgadmin: SELECT rolname, rolpassword FROM pg_authid; This requires superuser privileges to protect the password.

What is the password of user postgres?

Through trial and error I found that the password for Postgre SQL 10 for the username postgres is "admin". I kept typing in different password until I reached that password. I am using pgAdmin 4 to test out my SQL Statements, POSTGRE SQL 10 is the first server connection set up using localhost.


3 Answers

I ran into the same problem recently. The solution below works for me. I'm using Windows btw, so you should try equivalent commands in your OS.

  1. Change METHOD of all rows in your pg_hba.conf file from scram-sha-256 to trust
  2. Add bin folder of Postgres installation to path, if you haven't
  3. Open command prompt and enter psql -U postgres. You won't be asked for password here.
  4. Enter \password postgres
  5. Choose and confirm your password
  6. Revert pg_hba.conf to original state

Now you should be able to enter password for postgres in pgAdmin.

like image 183
dlam Avatar answered Oct 17 '22 08:10

dlam


Just for reference: I ran into the same issue on ubuntu-20.04 running postgresql-13.1. To solve it with this configuration I had to run the following commands in the terminal:

  1. sudo su postgres
  2. psql
  3. \password postgres
  4. enter your password twice

Afterwards, I could log in through pgAdmin4 as usual, providing the set password.

like image 13
eo_coder_jk Avatar answered Oct 17 '22 06:10

eo_coder_jk


The method that worked for me (Windows 10 x64, PostgreSQL 13):

  1. Edit C:\Program Files\PostgreSQL\13\data\pg_hba.conf and set "METHOD" column values to trust (security breach, only for testing purposes)
  2. Open Powershell as admin, go to C:\Program Files\PostgreSQL\13\bin
  3. Type pg_ctl reload, press Enter.
  4. Launch pgAdmin again
like image 3
Alberto Luengo Cabanillas Avatar answered Oct 17 '22 06:10

Alberto Luengo Cabanillas