Search code examples
postgresqlubuntupgadmin-4

pgAdmin and terminal: FATAL: password authentication failed for user


sup guys! I'm trying to create a server local in pdAdmin 4, but everytime i'm trying to create i get this error:

[Error in pgAdmin]

1

in case 'veterano' its my username...

my tries to make this run (but doesnt work)

Checking if Postgres Service is Installed correctly:

$ sudo systemctl is-active postgresql terminal back: active

$ sudo systemctl is-enabled postgresql terminal back: enabled

$ sudo systemctl status postgresql terminal back: active (exited)

$ sudo pg_isready terminal back: /var/run/postgresql:5433 - accepting connections

My configuration to pg_hba.conf :

local   all             postgres                                peer

# TYPE  DATABASE        USER            ADDRESS                 METHOD

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

(every time after change something in pg_hba.conf I run $ sudo systemctl restart postgresql to restart postgress service.)

Checking psql and the new superusers: $ sudo -u postgres createuser -s $USER

terminal back createuser: error: creation of new role failed: ERROR: role "veterano" already exists if I try psql -U veterano i can login... so i try \du to check list of roles terminal back

                                    List of roles
  Role name  |                         Attributes                         | Member of 
-------------+------------------------------------------------------------+-----------
 postgres    | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
 veterano    | Superuser, Create role, Create DB                          | {}

So I try create a localhost server in terminal: $ psql -h localhost -d mydatabase -U veterano -p 5432

terminal back: Password for user veterano:

(I put my password maked with ALTER USER veterano PASSWORD 'newPassword';)

terminal back error psql: error: FATAL: password authentication failed for user "veterano"

I really don't know what to do... I tried everything and still cant create a local server in pgAdmin 4 or directly in terminal.

Using Ubuntu 20.04.2 LTS

(Sorry for my english )


Solution

  • This is probably too late. but I have the same issue with veterano, and what I did was to change the password for the account "postgres" that I have : (For those who don't know, postgresql has a user named "postgres" by default after installation)

    Steps: Access PSQL

    $ sudo su - postgres
    

    Then try to change the password for "postgres" user by typing :

    postgres=# \password
    

    You can then specify any password you want for this account. Once thats done, you can use pgAdmin to connect using "postgres" username and the password that you just set.