访问数据库postgresql:密码身份验证失败

访问数据库postgresql:密码身份验证失败,postgresql,postgresql-9.5,Postgresql,Postgresql 9.5,我不熟悉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

我不熟悉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:致命:用户“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上运行

谢谢你的帮助,
Antoine是您的数据库密码,如果不是,请输入您的数据库密码 您在安装Postgres时提供的信息

  • 在Md5方法中,使用安装PostgreSQL时提供的数据库密码
  • 检查密码是否存在于.pgpass文件中
  • 对等身份验证与OS postgres用户一起工作,因此检查OS用户是否必须使用NOPASSWD启用
  • 最后,您可以对本地连接使用信任身份验证方法

  • 123是我给用户antoine和alter user antoine的密码,密码为“123”,我还使用了:将数据库cpf ietest的所有特权授予antoine;感谢您的回答,我不记得在安装时提供了密码,我如何检索它?请在postgres home directoryOk中签入.pgpass文件,以便在/etc/postgresql/9.5/main中我没有任何名为.pgpass的文件,它应该在哪里?如果文件不存在,您可以手动创建并使用它。好吧,我在试你告诉我的