无法使用DBeaver连接到本地postgresql数据库

l3zydbqr  于 2023-01-13  发布在  PostgreSQL
关注(0)|答案(4)|浏览(1042)

我尝试连接到一个postgresql数据库,它是在localhost:5432,但我一直得到错误:致命:用户“"的身份验证失败。
我在运行Centos7的虚拟机上安装了Postgres11。通过命令行创建了一个名为business_db的数据库。
我已经检查过了,postgresql正在localhost:5432上运行。
我的pg_hba.conf文件是这样的:

# 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

pg_ident.conf文件不包含任何配置:

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

# MAPNAME       SYSTEM-USERNAME         PG-USERNAME

数据库存在,如以下命令所示:

我以“dev”用户身份登录到系统,但是,无论我在测试连接时尝试什么,我总是得到错误:

我也尝试将用户设置为postgres并使用我的系统密码,但得到同样的错误。我错过了什么?

ntjbwcob

ntjbwcob1#

当你使用JDBC时,你必须使用口令认证,identpeer都不能胜任。
您需要添加,例如:

host    all             all             127.0.0.1/32           md5

位于pb_hba.conf的顶部
(如果使用scram-sha-256,请将其替换为md5

9gm1akwq

9gm1akwq2#

如果不想输入密码,请将ident更改为trust;如果想输入密码,请将x1m0 n1 a更改为md5
然后重新加载PostgreSQL服务器。

g0czyy6m

g0czyy6m3#

删除任何空格从你的密码,这对我工作

km0tfn4u

km0tfn4u4#

在(Ubuntu OS)中,通过以下方式更改(或设置)密码可解决此问题:
1-在终端中,运行以下命令:

sudo -u postgres psql template1

2-然后运行以下命令:

ALTER USER postgres with encrypted password 'your_password';

相关问题