Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql pgcrypto:无法访问普通用户_Postgresql_Postgresql 12_Pgcrypto - Fatal编程技术网

Postgresql pgcrypto:无法访问普通用户

Postgresql pgcrypto:无法访问普通用户,postgresql,postgresql-12,pgcrypto,Postgresql,Postgresql 12,Pgcrypto,我需要在postgresql 12实例上启用pgcrypto 我启用了扩展并检查它是否正常: postgres=# CREATE EXTENSION pgcrypto; CREATE EXTENSION postgres=# SELECT digest('blah', 'sha256'); digest ------------------------------------------------------------------

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

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

postgres=# CREATE EXTENSION pgcrypto;
CREATE EXTENSION
postgres=# SELECT digest('blah', 'sha256');
                               digest
--------------------------------------------------------------------
 \x8b7df143d91c716ecfa5fc1730022f6b421b05cedee8fd52b1fc65a96030ad52
(1 row)
我遵循了我读到的建议,所以:

postgres=# GRANT EXECUTE ON FUNCTION digest(bytea,text) TO normaluser;
GRANT
postgres=# GRANT EXECUTE ON FUNCTION digest(text,text) TO normaluser;
GRANT
遗憾的是,仍然无法对“普通用户”使用该函数


欢迎任何提示,谢谢:)

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

TL;博士;:在创建扩展pgcrypto之前连接到正确的数据库

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