Postgresql 的容器中没有权限初始化 PostGIS

Postgresql 的容器中没有权限初始化 PostGIS。Podman/Docker 创建的 PostGIS 容器,初始化 PostGIS 模块权限报错! > must be superuser to ……

Postgresql 的容器中没有权限初始化 PostGIS

问题描述

Podman/Docker 创建的 PostGIS 容器,初始化 PostGIS 模块权限报错!

must be superuser to ……

目标

希望目标用户拥有超级用户权限

解决方式

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# 登录到容器内部
podman exec -it -u postgres postgis /bin/bash

# 登录数据库
psql

# 查询超级用户是哪一个(rolsuper 的值为 t 的是超级用户)
SELECT * FROM pg_authid;

# 退出当前登录
exit

# 用超级用户登录(-U 指定用户,-d 指定数据库)
psql -U superuser_sys -d postgres;

# 赋予目标用户(postgres)超级用户权限
alter user postgres with superuser;
Licensed under CC BY-NC-SA 4.0
Gear(夕照)的博客。记录开发、生活,以及一些不足为道的思考……