PostgreSQL: Admin: General

 16th December 2020 at 4:38pm

The PostgreSQL User Account

应该由单独的系统用户(而不是 root 或者其他日常有使用的用户)来运行 PostgreSQL。一般会使用 postgres 用户来运行。

对于 Arch Linux,安装 PostgreSQL 后,会 自动生成 postgres 用户,并且运行 server 时也是 使用此用户

仅能 使用该用户(sudo -iu postgres)来运行管理 PG 的任何命令,如 psqlinitdbcreatedbdropdb 等。如果你在 initdb 时允许 group access (-g),则 postgres 组上的用户有读权限,需要重启 server 生效。实现上是给 data 目录设置上不同的文件和目录权限。