我试图login到我的数据库,并得到这个错误…
root@---:~# psql -U user database psql: FATAL: Peer authentication failed for user "user"
这是什么意思? 我很确定,我可以通过将同伴放入我的pg_hba.conf来解决这个问题,但我不确定是否应该这样做。
这意味着系统尝试了对等身份validation( …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.confconfiguration为本地连接的对等身份validation吗?
如果是这样,您可能需要将其更改为更合适的auth方法,如md5或trust (不推荐)。
有关更多信息,请参阅Postgres手册 。
您应该明确指定--host参数,然后使用密码身份validation代替Peer 。
例:
psql -u someuser -h 127.0.0.1
首先做一个sudo su databaseuser; 然后在-U开关下运行psql命令