我有两个带有 Postgresql 的 Linux 系统:
在两者上,我创建了相同的用户和数据库(具有相同的所有者)。它们还具有相同的 .pgpass 文件和或多或少相同的 pg_hba.conf 文件。两个 pg_hba.conf 文件都包含:
local all postgres peer
local all all peer
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
Run Code Online (Sandbox Code Playgroud)
我还应该补充一点,两台机器上都没有指定 PGHOST。
然而,在 (1) 上我可以直接运行以下命令:
psql -d myDB
Run Code Online (Sandbox Code Playgroud)
在(2)上我需要指定用户名和主机名:
psql -d myDB -U myDBuser -h localhost
Run Code Online (Sandbox Code Playgroud)
或者我收到以下错误:
psql: FATAL: role "ubuntu" does not exist
Run Code Online (Sandbox Code Playgroud)
为什么会这样,我怎样才能使(2)像(1)一样(以节省一些打字时间)?
postgresql ×1