0
我試圖在NixOS使用PostgreSQL,面對下面的錯誤,我收到了類似的錯誤,當只運行$ psql
,使用默認用戶(我的用戶名)。看來我的postgres安裝沒有可用於創建其他角色或運行任何命令的角色。
如何爲我的postgres用戶創建一個角色,以便我可以發出命令?
我已經安裝postgres的與$ nix-env -i postgres
和根據NixOS manual配置,加入
services.postgresql.enable = true;
services.postgresql.package = pkgs.postgresql94;
到我/etc/nixos/configuration.nix
配置文件。
我還添加Postgres的認證如本example configuration建議,所以我/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
'';
我還推薦閱讀NixOS手冊中的postgresql部分https://nixos.org/nixos/manual/index.html#module-postgresql – iElectric
請注意,這不會再發生在stateVersion> = 17.09的系統上,其中'postgres '現在是默認的超級用戶。 – danbst