数据库身份验证失败-Postgres

时间:2018-11-10 11:35:25

标签: javascript node.js postgresql

我不知道为什么收到此错误消息:

DB authentication failed:
    SequelizeConnectionError: Ident authentication failed for user "smemamian"
        at connection.connect.err (/home/sunyar/API/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:108:24)

\l命令行输出:

postgres=> \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 sunyar    | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres         +
           |          |          |             |             | postgres=CTc/postgres+
           |          |          |             |             | sunyardb=CTc/postgres+
           |          |          |             |             | smemamian=c/postgres
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres

我的数据库连接变量:

DB_CONNECTION_URL = 'postgres://smemamian:123456@localhost:5432/sunyar'

1 个答案:

答案 0 :(得分:0)

默认情况下,postgres使用基于IDENT的身份验证。因此,“身份验证失败”与 pg_hba.conf 配置文件有关。在psql命令行中,您可以通过键入以下内容找到该文件:

postgres=> show hba_file;

在此处查看参考:https://www.postgresql.org/docs/9.1/auth-pg-hba-conf.html