PostgreSQL - 致命:用户的身份验证失败 [英] PostgreSQL - FATAL: Ident authentication failed for user

查看:43
本文介绍了PostgreSQL - 致命:用户的身份验证失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据库 mytestdb

我想将此表导入 hdfs.

I would like to import this table into hdfs.

bin/sqoop import --connect 'jdbc:postgresql://127.0.0.1/mytestdb' --username user -P --table employees --target-dir /user/postgres

但是,我一直收到错误消息:

But, I keep receiving an error:

警告:连接到 127.0.0.1:5432 时发生 SQLExceptionorg.postgresql.util.PSQLException:致命:身份验证失败对于用户用户"org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:473)

WARNING: SQLException occurred while connecting to 127.0.0.1:5432 org.postgresql.util.PSQLException: FATAL: Ident authentication failed for user "user" at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:473)

/var/lib/pgsql/data/pg_hba.conf设置如下:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

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

推荐答案

我从网络上几个不同来源的组合中找到了一个可行的解决方案.

I found a workable solution from a combination of several different sources on the web.

编辑配置文件

nano /var/lib/pgsql/data/pg_hba.configuration

将前两个 ident 替换为 md5,如下所示:

Replace the first two ident's with md5, like so:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# 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     postgres                                peer
#host    replication     postgres        127.0.0.1/32            ident
#host    replication     postgres        ::1/128                 ident

保存文件.

然后,重启服务器

sudo systemctl restart postgresql

最后,将数据库testdb的所有权限授予hduser;

这篇关于PostgreSQL - 致命:用户的身份验证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆