2016-11-17 80 views
1

我知道有大量的帖子与密切的消息。我读过所有希望。并没有找到答案。一些提议使用-h localhostlocal跳转到host规则hba.conf。有人说设置trustlocal ...但我想peer身份验证,而不是TCP而不是信任!Postgres - 同行认证 - psql:致命:角色“xxxx”不存在

,所以我有两个OSDB用户VAO:

t=# \! who am i 
vao  pts/8  2016-11-11 12:23 (10.1.10.158) 

t=# \du+ vao 
        List of roles 
Role name | Attributes | Member of | Description 
-----------+------------+-----------+------------- 
vao  | Superuser | {}  | 

,然而当我尝试给psql我得到错误:

$ psql t 
psql: FATAL: role "vao" does not exist 

根据docs

The peer authentication method works by 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.

Peer authentication is only available on operating systems providing the getpeereid() function, the SO_PEERCRED socket parameter, or similar mechanisms. Currently that includes Linux, most flavors of BSD including OS X, and Solaris.

所以我看,如果Debian支持getpeereid() 或SO_PEERCRED并拼命挖掘解释。

直到我重新评估我明显缺乏环境设置。如果psql里没有找到用户,也许它没有找到一个socket .. 所以我检查unix_socket_directoriespostgresql.conf 并根据 psql的手册:

--host=hostname Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix-domain socket.

尝试psql t -h '/path/to/unix_socket_directories',瞧 - 我在那里

而且这不是我第一次踩这个耙子! 所以我把它张贴在这里 - 希望它能帮助别人。

回答

1

错误是误导。

代替

psql: FATAL: role "xxx" does not exist

应该

psql: FATAL: socket "yyy" does not exist

或其他任何东西,这会导致我们的想法,认为我们缺乏Environment Variables

所以不便像export PGHOST=/var/run/postgresql能治愈ilness

相关问题