Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot connect to local postgresql DB using DBeaver

I'm trying to connect to a postgresql database which is in localhost:5432 but I keep getting the error: FATAL: Ident authentication failed for user "".

I installed Postgres11 on virtual machine running Centos7. Created a database through command line, with the name business_db.

I've checked and postgresql is running in localhost:5432.

My pg_hba.conf file is like this:

# TYPE  DATABASE        USER            ADDRESS                 METHOD
local   all             all                                     peer
host    all             all             127.0.0.1/32           ident
host    all             all             ::1/128                 ident
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            ident
host    replication     all             ::1/128                 ident

The pg_ident.conf file doesn't hold any configurations:

# Put your actual configuration here
# ----------------------------------

# MAPNAME       SYSTEM-USERNAME         PG-USERNAME

The database exists as shown by the command:

Database list

I'm logged into the system as "dev" user but., whatever I try while testing connection whit DBeaver, I allways get the error:

ERROR

I also tried to set User as postgres and use my system password but get the same error. What am I missing?

like image 230
ayaros Avatar asked Feb 14 '20 14:02

ayaros


People also ask

How do I access PostgreSQL database?

The default username for postgres is postgres. (If you are using Advanced Server it is enterprisedb.) On a Mac or Windows, you are able to connect to the default instance by simply hitting enter at the shell or command prompt when trying to run psql and keying in the password.


1 Answers

When you use JDBC, you have to use password authentication. Neither ident nor peer will work for that.

You will need to add, e.g.:

host    all             all             127.0.0.1/32           md5

at the top of your pb_hba.conf

(replace md5 with scram-sha-256 if you are using that)

like image 192
a_horse_with_no_name Avatar answered Oct 10 '22 04:10

a_horse_with_no_name