6

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 )

eshirvana
  • 23,227
  • 3
  • 22
  • 38
Jesse Marques
  • 73
  • 1
  • 1
  • 4
  • The only I can say is that the password you are entering is not the password you created for user `veterano`. Login in again using `peer` authentication; `psql -U veterano` and do the `ALTER USER veterano PASSWORD 'newPassword'` again to make sure you have the correct password set up. Also are you sure you have only one Postgres cluster running? Where did you install Postgres from the Ubuntu or Postgres repos? – Adrian Klaver May 17 '21 at 15:15
  • Look in the log file for the full ERROR message. Unauthenticated users are not given all the info which the system has. – jjanes May 17 '21 at 16:24
  • I install postgres using this tutorial maked for "Grogu" https://stackoverflow.com/questions/53267642/create-new-local-server-in-pgadmin I try again login using `peer` authentication and `ALTER USER veterano PASSWORD 'newPassword' ` and still get error password authentication for "veterano" – Jesse Marques May 17 '21 at 17:17
  • FIX IT! I was already using port 5432 with a docker, it was just a port conflict, I disconnected the docker and finally I got it, very strange that he did not specify the error as a port conflict! Thanks all! – Jesse Marques May 17 '21 at 18:48
  • 1
    There was no port conflict. You did not specify a port when connecting so `psql` used the default of `5432` and connected you to the docker server which did not have the user/password combo you where supplying. – Adrian Klaver May 17 '21 at 19:59
  • Hi guys, I guess you got this error after you drop 'postgres' database right ? – Thân Hoàng Sep 20 '21 at 03:00

4 Answers4

13

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.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Aldo aldo
  • 382
  • 1
  • 2
  • 10
  • 1
    This does not solve the problem of unauthenticated, but instead you're using the postgres super user by setting it a password. – Mazzy Apr 29 '22 at 10:20
2

Either you didn't set a password for the user, or you set a different password.

Connect using psql with psql -U veterano and set the password:

veterano=> \password
Enter new password: 
Enter it again:

Now you should be good.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
0

Try putting quotation marks '' on your password at your config file.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
0
  1. First we have to get inside postgres through using

    sudo -u postgres psql postgres

  2. Enter password for user postgres

Now the terminal will be like this:

postgres=#

  1. Now enter the given line after postgres=# CREATE USER username WITH PASSWORD 'your password'; (put your password inside quotes('') and don't forget semicolon(;)
Anish R
  • 1
  • 1