出于安全原因,在默认情况下,initdb创建的新集群只能由集群所有者访问。
allow-group-access选项允许与cluster初始化宿主属于同一组的任何用户读取集群中的文件。
这对于普通用户非常方便。
https://www.postgresql.org/docs/12/app-initdb.html
1.宿主用户postgres初始化并启动数据库
1 ‐‐使用postgres用户初始化,并指定‐‐allow‐group‐access
2 $initdb‐‐allow‐group‐access‐D/home/postgres/data5432‐Upostgres‐W
3
4 ‐‐启动数据库
5 $pg_ctl‐D/home/postgres/data5432start&
1 $idjerome
2 uid=1000(jerome)gid=1000(jerome)groups=1000(jerome),1001(postgres)
3
4 $ll/home/postgres/data5432/
5 total64
6 drwxr‐x‐‐‐.5postgrespostgres41Feb716:26base
7 ‐rw‐r‐‐‐‐‐.1postgrespostgres67Feb716:28current_logfiles
8 drwxr‐x‐‐‐.2postgrespostgres4096Feb716:26global
9 drwxr‐x‐‐‐.2postgrespostgres6Feb716:26pg_commit_ts
10 drwxr‐x‐‐‐.2postgrespostgres6Feb716:26pg_dynshmem
11 ‐rw‐r‐‐‐‐‐.1postgrespostgres4513Feb716:26pg_hba.conf
12 ‐rw‐r‐‐‐‐‐.1postgrespostgres1636Feb716:26pg_ident.conf
13 drwxr‐x‐‐‐.2postgrespostgres78Feb716:28pg_log
14 drwxr‐x‐‐‐.4postgrespostgres68Feb716:33pg_logical
15 drwxr‐x‐‐‐.4postgrespostgres36Feb716:26pg_multixact
16 drwxr‐x‐‐‐.2postgrespostgres18Feb716:28pg_notify
17 drwxr‐x‐‐‐.2postgrespostgres6Feb716:26pg_replslot
18 drwxr‐x‐‐‐.2postgrespostgres6Feb716:26pg_serial
19 drwxr‐x‐‐‐.2postgrespostgres6Feb716:26pg_snapshots
20 drwxr‐x‐‐‐.2postgrespostgres6Feb716:26pg_stat
21 drwxr‐x‐‐‐.2postgrespostgres25Feb716:34pg_stat_tmp
22 drwxr‐x‐‐‐.2postgrespostgres18Feb716:26pg_subtrans
23 drwxr‐x‐‐‐.2postgrespostgres6Feb716:26pg_tblspc
24 drwxr‐x‐‐‐.2postgrespostgres6Feb716:26pg_twophase
评论