对等认证对于 postgresql 来说意味着什么?

对等认证对于 postgresql 来说意味着什么?

我正在尝试登录我的数据库并收到此错误......

root@---:~# psql -U user database
psql: FATAL:  Peer authentication failed for user "user"

这是什么意思?我很确定我可以通过将 peer 放入我的 pg_hba.conf 来修复它,但我不确定是否应该这样做...

答案1

这意味着系统尝试进行对等身份验证(…obtaining the client's operating system user name from the kernel and using it as the allowed database user name (with optional user name mapping). This method is only supported on local connections.),并且失败了。

您的 pg_hba.conf 是否配置了本地连接的对等身份验证?
如果是,您可能需要将其更改为更合适的身份验证方法,例如md5trust(不推荐)。
请参阅Postgres 手册了解更多信息。

答案2

您应该明确指定--host参数,然后密码将使用身份验证来代替同行

例子:

psql -u someuser -h 127.0.0.1

答案3

这是一条建议:仅使用 md5 或 trust(不推荐)来访问您的数据库。我的 pg_hba.conf 中包含 Peer 扰乱了我对 Postgresql 的理解。我仍在学习,但该文件中包含 md5 使身份验证变得可预测且易于理解。

答案4

首先执行 sudo su databaseuser; 然后运行不带 -U 开关的 psql 命令

相关内容