用户相关操作

最近更新时间: 2024-10-17 17:10:00

  • \du显示当前集群中所有数据库用户。
postgres=# \du

                                    List of roles
  Role name   |                         Attributes                         | Member of 
---------------+------------------------------------------------------------+-----------
 audit_admin  | No inheritance                                             |{}
 mls_admin    | No inheritance                                             | {}
 tbase        | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
 tbase01_admin | Superuser, Create role, CreateDB                          | {}
  • \du+显示当前集群中所有数据库用户(包含注释)。
postgres=# \du+
                                    List of roles
  Role name   |                         Attributes                         | Member of |Description 
---------------+------------------------------------------------------------+-----------+-------------
 audit_admin  | No inheritance                                             |{}        | 
 mls_admin    | No inheritance                                             |{}        | 
 tbase        | Superuser, Create role, Create DB, Replication, Bypass RLS | {}        | 
 tbase01_admin | Superuser, Create role, CreateDB                          | {}        |
  • 创建一个新的用户。
postgres=# create role pgxc with login ;
CREATE ROLE
  • 配置用户密码。
postgres=# \password pgxc
Enter new password: 
Enter it again: