用户

设置/重置 Postgres 用户密码

\password username

// 设置/重置 PostgreSQL 数据库用户密码 (psql)

例如:更改当前用户“postgres”的密码

\password postgres
Enter new password: xxxx
Enter it again: xxxx


显示所有用户

select * from pg_user;

// 显示 PostgreSQL 数据库用户 (SQL)

\du
                                   List of roles
 Role name |                         Attributes                         | Member of 
-----------+------------------------------------------------------------+-----------
 testrole  |                                                            | {} 
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

// 显示 PostgreSQL 数据库角色 (psql)


登录并进入 Postgres 终端

$ psql -U testuser mytest
Password for user testuser: ......
psql (9.6.12)
Type "help" for help.

// 登录 PostgreSQL:psql -U 用户 数据库 (psql)