【问题标题】:Accessing database postgresql : password authentification failed访问数据库 postgresql:密码验证失败
【发布时间】:2018-11-11 08:07:19
【问题描述】:

我是 postgreSQL(和 SQL 顺便说一句)的新手。我正在尝试在本地连接到数据库。 所以这是我正在使用的命令:

create user adeyris;
alter user antoine with login;
alter user antoine with encrypted password '123';
alter user antoine with createdb;
create database cpf_ietest;

我现在离开 psql,像这样加载我的转储:

psql -h localhost -U antoine -d cpf_ietest -f /home/antoine/Downloads/cpf_ietest.sql

我被要求输入密码,我输入 123,然后我收到以下错误:

psql: FATAL: 用户“antoine”的密码验证失败

这是我的 pg_hba.conf 文件:

# Database administrative login by Unix domain socket
local   all             postgres                                peer

# 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            md5
#host    replication     postgres        ::1/128                 md5

在第一个未注释的行中,我将“peer”修改为“md5”。 我在 Ubuntu 16.04 和 postgresql 9.5 上运行。

感谢您的帮助, 安托万

【问题讨论】:

    标签: postgresql postgresql-9.5


    【解决方案1】:

    is 123 是您的数据库密码,如果不是,请输入您的数据库密码 您在安装 Postgres 时提供的

    【讨论】:

    • 123 是我通过 alter user antoine with password '123' 给用户 antoine 的密码
    • 哦,我也用过:将数据库 cpf_ietest 的所有权限授予 antoine;
    【解决方案2】:
    1. 在 Md5 方法中使用您在安装 PostgreSQL 时提供的数据库密码。
    2. 检查 .pgpass 文件中是否存在密码。
    3. 对等身份验证与 OS postgres 用户一起使用,因此检查天气 OS 用户必须使用 NOPASSWD 启用
    4. 最后您可以对本地连接使用信任身份验证方法。

    【讨论】:

    • 感谢您的回答,我不记得在安装时提供了密码,我该如何找回?
    • 在 postgres 主目录中签入 .pgpass 文件
    • 好的,所以在 /etc/postgresql/9.5/main 我没有任何名为 .pgpass 的文件,它应该在哪里?
    • 如果文件没有退出,那么您可以手动创建并使用它。 serverfault.com/questions/285219/…
    • 好的,我正在尝试你告诉我的内容
    猜你喜欢
    • 2016-02-13
    • 2011-12-03
    • 1970-01-01
    • 1970-01-01
    • 2017-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多