【问题标题】:pgcrypto: unable to normal userpgcrypto:无法正常用户
【发布时间】:2021-01-13 11:08:57
【问题描述】:

我需要在 postgresql 12 实例上启用 pgcrypto

我启用了扩展并检查它是否正常:

postgres=# CREATE EXTENSION pgcrypto;
CREATE EXTENSION
postgres=# SELECT digest('blah', 'sha256');
                               digest
--------------------------------------------------------------------
 \x8b7df143d91c716ecfa5fc1730022f6b421b05cedee8fd52b1fc65a96030ad52
(1 row)

我遵循了我在 SO 上阅读的建议:

postgres=# GRANT EXECUTE ON FUNCTION digest(bytea,text) TO normaluser;
GRANT
postgres=# GRANT EXECUTE ON FUNCTION digest(text,text) TO normaluser;
GRANT

遗憾的是,仍然无法通过“普通用户”使用该功能。

normaluser@planck:5432/cryptodb> SELECT digest('blah', 'sha256');
ERROR:  42883: function digest(unknown, unknown) does not exist
LINE 1: SELECT digest('blah', 'sha256');
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
LOCATION:  ParseFuncOrColumn, parse_func.c:631
Time: 52,065 ms

欢迎任何提示,谢谢:)

【问题讨论】:

    标签: postgresql postgresql-12 pgcrypto


    【解决方案1】:

    在问题中,您可以看到我在创建扩展程序时以超级用户 postgres 的身份连接,而 不是 进入数据库 cryptodb 曾经是用户 normaluser。 所以我用postgres 连接到数据库cryptodb,现在normaluser 可以在cryptodb 上下文中使用pgcrypto 函数digest

    TL;DR; : CREATE EXTENSION pgcrypto;之前连接到正确的数据库

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-20
      • 2016-05-20
      • 2012-02-27
      • 1970-01-01
      相关资源
      最近更新 更多