psql:严重:用户“ dev”的对等身份验证失败。 [英] psql: FATAL: Peer authentication failed for user "dev"

查看:109
本文介绍了psql:严重:用户“ dev”的对等身份验证失败。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我创建一个新用户,但它无法登录数据库时。

我这样做是这样的:

when i create a new user, but it cannot login the database.
I do that like this:

postgres@Aspire:/home/XXX$ createuser dev
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) y

然后创建一个数据库:

postgres@Aspire:/home/XXX$ createdb -O dev test_development

之后,我尝试 psql -U dev -W test_development 登录,但收到错误:

after that, I try psql -U dev -W test_development to login, but get the error:

psql: FATAL:  Peer authentication failed for user "dev"


$ b的对等身份验证失败$ b

我试图解决问题,但失败了。

I tried to solve the problem but failed.

推荐答案

尝试:

psql -U user_name  -h 127.0.0.1 -d db_name

其中


  • -U 是数据库用户名

  • -h 是本地服务器的主机名/ IP,从而避免使用Unix域套接字

  • -d 是要连接到的数据库名称

  • -U is the database user name
  • -h is the hostname/IP of the local server, thus avoiding Unix domain sockets
  • -d is the database name to connect to

然后进行评估作为Postgresql的网络连接,而不是Unix域套接字连接,因此不评估为您可能会在 pg_hba.conf 中看到本地连接:

This is then evaluated as a "network" connection by Postgresql rather than a Unix domain socket connection, thus not evaluated as a "local" connect as you might see in pg_hba.conf:

local   all             all                                     peer

这篇关于psql:严重:用户“ dev”的对等身份验证失败。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆