Pie*_*aud 5 postgresql nixos nix
我已经安装了 PostgreSQL:
nix-env -iA nixos.postgresql
Run Code Online (Sandbox Code Playgroud)
现在当我使用 时psql,我得到:
psql: error: connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
Run Code Online (Sandbox Code Playgroud)
我必须添加一些东西/etc/nixos/configuration.nix吗?
更新
我尝试像此链接那样进行操作(即,将其安装在nix-shell而不是安装在中nix-env),但我仍然遇到相同的错误:
$ nix-shell --pure shell.nix
done
server started
$ psql
psql: error: could not connect to server: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/mnt/c/Users/Pierre-Olivier/nix/psql/.pg/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)
psql是PostgreSQL 交互终端。
您想要做的是在不首先运行 PostgreSQL 的情况下连接到数据库。
按着这些次序:
initdb -D .datapg_ctl -D .data -l logfile startpg_ctl -D .data statuspsql -d postgres(默认情况下,创建 postgres 数据库)最后,确保pg_ctl -D .data stop在离开 nix shell 时停止数据库。
| 归档时间: |
|
| 查看次数: |
3306 次 |
| 最近记录: |