psql:FATAL:role“postgres”不存在(使用-h localhost选项) [英] psql: FATAL: role "postgres" does not exist (with -h localhost option)
问题描述
我在我的本地计算机上安装了Postgres。
I have Postgres installed in my local machine.
当我执行
psql -U postgres -d buzzsumo
它正确地要求我的密码给用户postgres 。
it correctly asks for my password to the user postgres.
但是,当我运行
psql -U postgres -d buzzsumo -h localhost
它会给我这个错误消息:
it gives me this error message:
psql:FATAL:角色postgres不存在
psql: FATAL: role "postgres" does not exist
在第一个例子中,我连接到我的本地服务器,这相当于传递localhost?
Why is this the case, when in the first example I am connecting to my local server, which is equivalent to passing in localhost?
推荐答案
不要说,但我猜你在MacOS或Linux上运行postgres。
You don't say but I'm guessing you're running postgres on either on MacOS or Linux.
第一种形式(没有-h)通过unix插座。第二种形式,用-h localhost通过TCP / IP连接到localhost(IP地址127.0.0.1)。
The first form (with no -h) connects via a "unix socket". The second form, with "-h localhost" connects via TCP/IP to localhost (IP address 127.0.0.1).
Postgres不同地处理这两种类型的连接 - 至少,它可以这样做。如果您检查pgsql / data / pg_hba.conf文件以查看为这两种类型的连接配置了什么认证机制。
Postgres treats these two types of connections differently - or at least, it can do so. If you check the "pgsql/data/pg_hba.conf" file to see what authentication mechanisms are configured for the two types of connections.
这篇关于psql:FATAL:role“postgres”不存在(使用-h localhost选项)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!