postgresql pg_dump: [archiver (db)] 与数据库“dbase”的连接失败:致命:用户“postgres”的对等身份验证失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35314862/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
pg_dump: [archiver (db)] connection to database "dbase" failed: FATAL: Peer authentication failed for user "postgres"
提问by basante
Solved: I added .pgpass in home.
解决:我在家里添加了.pgpass。
I have the line:
我有这条线:
host all all 127.0.0.1/32 md5
in /etc/postgresql/9.4/main/pg_hba.conf but when I run:
在 /etc/postgresql/9.4/main/pg_hba.conf 但当我运行时:
# pg_dump -U postgres dbase -f dbase.sql
# pg_dump -U postgres dbase -f dbase.sql
I get:
我得到:
pg_dump: [archiver (db)] connection to database "dbase" failed:
FATAL: Peer authentication failed for user "postgres"
pg_dump: [archiver (db)] 与数据库“dbase”的连接失败:
致命:用户“postgres”的对等身份验证失败
回答by Bobo
The Problem you have is, that if u dont define the Host, your system will decide.
你遇到的问题是,如果你不定义主机,你的系统将决定。
explicit add "-h localhost", this will fix it
显式添加“-h localhost”,这将修复它
回答by Diego Tejada
If adding -h localhost doesn't work you can try adding -h 127.0.0.1
如果添加 -h localhost 不起作用,您可以尝试添加 -h 127.0.0.1
pg_dump -h 127.0.0.1 -U <username> -d <database_name> -W > bk_name.sql