我正在配置postgres数据库,并且我看到默认角色pg_monitor、pg_read_all_settings、pg_read_all_stats、pg_signal_backend和pg_stat_scan_tables都不能登录。我不知道第一步会是什么。以下是\l和\du的输出:
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-------------------------
confdb02 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres +
| | | | | postgres=CTc/postgres +
| | | | | confluence=CTc/postgres
postgres | postgres | 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
(4 rows)
postgres=# \du
List of roles
Role name | Attributes | Member of
----------------------+------------------------------------------------+--------------------------------------------------------------
confluence | Superuser, Create role, Create DB | {}
pg_monitor | Cannot login | {pg_read_all_settings,pg_read_all_stats,pg_stat_scan_tables}
pg_read_all_settings | Cannot login | {}
pg_read_all_stats | Cannot login | {}
pg_signal_backend | Cannot login | {}
pg_stat_scan_tables | Cannot login | {}
postgres | Superuser, Create role, Create DB, Replication | {}
Thanks!
发布于 2022-03-06 18:06:04
使用以下命令将属性登录添加到角色:
ALTER ROLE username LOGIN;
不要忘记用户需要一个密码:
ALTER ROLE username WITH PASSWORD 'user_secret_password';
您还需要授予对数据库的权限,例如:
GRANT SELECT ON DATABASE databasename TO username;
权限列表如下:
SELECT
INSERT
UPDATE
DELETE
TRUNCATE
REFERENCES
TRIGGER
CREATE
TEMPORARY or TEMP
EXECUTE
USAGE
ALL PRIVILEGES
https://stackoverflow.com/questions/65568727
复制相似问题