0

我想用 Erlang 和 epgsql 运行一个简单的 PostgreSQL 查询,类似于Erlang 和 PostgreSQL。我正进入(状态

** exception error: no match of right hand side value 
{error,
    {authentication,
        [{severity,'Ð\222Ð\220Ð\226Ð\235Ð\236'},
         {code,"28000"},
         {message,[208,191,208,190,208,187,209,140,208,183,208,190,208,178,208,176,209,130,208,181|...]},
         {file,"auth.c"},
         {line,302},
         {routine,"auth_failed"}]}}

{ok, C} = pgsql:connect("localhost", 
                        "postgres", 
                        "password", 
                        [{database, "postgres"}]).

我的 PostgreSQL 实例工作正常,我可以将表添加到我的数据库或运行简单的查询。但我需要用epgsql来做。此外,我无法阅读错误消息,这是我可以看到的:

[208,191,208,190,208,187,209,140,208,183,208,190,208,178,208,176,209,130,208,181|...]
4

2 回答 2

1

我安装了egpsql,直接做了测试,确认第二个参数forconnect是用户名,第三个是密码:

{ok, C} = pgsql:connect("localhost", "username", "password", [{database, "db_name"}]).
{ok, Columns, Rows} = pgsql:squery(C, "select * from myschema.mytable").
于 2013-04-01T17:04:28.967 回答
0

我在使用epgsql:connect函数时看到了类似的错误28000 INVALID AUTHORIZATION SPECIFICATION 。

我遵循了人们的建议,将 pg_hba.conf 本地方法类型更改为 trust 和 ident。但没有运气!通过创建新用户并在 psql 端授予权限来尝试。但没有运气。

local   all             all                                    password #trust

最后,在 pg_hba.conf 文件中进行以下更新后(重新启动 postgresql 服务),它在 centos 7 上为我工作。

host    all             all             127.0.0.1/32            password #ident
于 2022-02-22T19:22:55.560 回答