gpt4 book ai didi

postgresql - PostGIS 仅适用于 root 用户

转载 作者:行者123 更新时间:2023-11-29 13:27:38 26 4
gpt4 key购买 nike

我有一个数据库,正在尝试将 PostGis 与它结合使用。当我运行时:

$ psql -h localhost -d $APP_DB_NAME -U $APP_DB_USER
# SELECT PostGIS_version();

我收到以下错误:

ERROR:  function postgis_version() does not exist
LINE 1: SELECT PostGIS_version();
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.

但是当我以root身份进入数据库时​​:

$ sudo su postgres -c psql $APP_DB_NAME
# SELECT PostGIS_version();

运行良好:

            postgis_version
---------------------------------------
2.1 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
(1 row)

我正在以根用户身份安装 PostGis 扩展,因为我的用户没有 super 用户访问权限。

$ su - postgres -c psql $APP_DB_NAME
# CREATE EXTENSION postgis;

最佳答案

我的猜测是,安装 postgis 的模式的所有者不是您登录的用户,而是“根”用户(即 postgres)。

$ psql postgres
postgres=# \dn
List of schemas
Name | Owner
--------------------+----------
public | postgres
pg_catalog | postgres
my_data | someuser

当以 postgres 身份连接时,postgis 在这种情况下可以工作,但如果您以任何其他用户身份连接,它将失败,并说它不存在,即使您尝试 create extension postgis它会说它已经安装了。

要更正此问题,请确保所有模式都归您实际连接的用户所有:

ALTER SCHEMA public OWNER TO my_user;

关于postgresql - PostGIS 仅适用于 root 用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30899384/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com