设置生产postgres(createdb权限)

问题描述 投票:0回答:1

我正在DigitalOcean上设置postgres。我已经设置了PG环境。 9s显然是编辑过的数据。为了方便ssl连接,存在~/.postgresql/root.crt

# env | grep PG
PGPORT=99999
PGPASSWORD=9999999999999
PGSSLMODE=require
PGUSER=doadmin
PGDATABASE=auth_service_prod
PGHOST=private-db-postgresql-sfo9-99999-do-user-9999999-9.a.db.ondigitalocean.com

调用createdb时失败:

# createdb
createdb: could not connect to database template1: FATAL:  pg_hba.conf rejects connection for host "10.999.9.99", user "doadmin", database "template1", SSL on
但是,

可以连接到psql。我对配置postgres允许doadmin创建数据库了解的不够多,但希望这里有一些有用的信息:

# psql
psql (11.7 (Debian 11.7-0+deb10u1), server 11.8)
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.

auth_service_prod=> \du
                                   List of roles
 Role name |                         Attributes                         | Member of 
-----------+------------------------------------------------------------+-----------
 _dodb     | Superuser, Replication                                     | {}
 doadmin   | Create role, Create DB, Replication, Bypass RLS            | {}
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

auth_service_prod=> \l
                                      List of databases
       Name        |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-------------------+----------+----------+-------------+-------------+-----------------------
 _dodb             | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 auth_service_prod | doadmin  | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 defaultdb         | doadmin  | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0         | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
                   |          |          |             |             | postgres=CTc/postgres
 template1         | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
                   |          |          |             |             | postgres=CTc/postgres
(5 rows)
postgresql
1个回答
0
投票

显然,DigitalOcean不允许postgres提供createdb。我删除了创建数据库的代码,并从其GUI“手动”创建了它们。该应用程序现在仅负责管理架构,而不负责数据库。

© www.soinside.com 2019 - 2024. All rights reserved.