Postgres创建管理员角色

时间:2022-12-18 08:12:00
--创建角色,赋予角色属性
create user batman password '12345' superuser createrole createdb
--添加到角色组
grant postgres to batman

以上是直接创建管理员角色,如果是修改一个角色为管理员角色的话

alter role spiderman createrole;

创建用户的格式为:

CREATE ROLE name [ [ WITH ] option [ ... ] ]

where option can be:

SUPERUSER
| NOSUPERUSER
| CREATEDB | NOCREATEDB
| CREATEROLE | NOCREATEROLE
| INHERIT | NOINHERIT
| LOGIN | NOLOGIN
| REPLICATION | NOREPLICATION
| BYPASSRLS | NOBYPASSRLS
| CONNECTION LIMIT connlimit
| [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password'
| VALID UNTIL 'timestamp'
| IN ROLE role_name [, ...]
| IN GROUP role_name [, ...]
| ROLE role_name [, ...]
| ADMIN role_name [, ...]
| USER role_name [, ...]
| SYSID uid

 

数据库的一些设置:

1、最大连接数设置 max_connections = 1000
2、转义打开 standard_conforming_strings = off