【发布时间】:2017-12-20 17:32:42
【问题描述】:
我尝试在 NixOS 上使用 postgresql,在运行 $ psql -U postgres 时遇到以下错误
$ psql -U postgres
psql: FATAL: role "postgres" does not exist
使用默认用户(我的用户名)简单地运行 $ psql 时,我遇到了类似的错误。我的 postgres 安装似乎没有可用于创建其他角色或运行任何命令的角色。
如何为我的 postgres 用户创建一个角色以便我可以发出命令?
我已经用$ nix-env -i postgres安装了postgres,按照NixOS manual配置,添加
services.postgresql.enable = true;
services.postgresql.package = pkgs.postgresql94;
到我的/etc/nixos/configuration.nix 配置文件。
我还按照 example configuration 中的建议添加了 postgres 身份验证,因此我的 /etc/nixos/configuration.nix 文件的 postgresql 行看起来像
# postgres
services.postgresql.enable = true;
services.postgresql.package = pkgs.postgresql94;
services.postgresql.authentication = lib.mkForce ''
# Generated file; do not edit!
# TYPE DATABASE USER ADDRESS METHOD
local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
'';
【问题讨论】:
标签: postgresql configuration nixos