Postgresql (pgsql) 客户端期望套接字位于与 postgrsql-server 不同的位置

ets*_*uer 4 postgresql

当尝试连接到我的工作站上本地运行的 postgres 时,我得到:

$ sudo -u postgres psql -c "create role ..."
could not change directory to "/home/esauer/workspace/cfme"
psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)

我的 postgres-server 安装在/var/run/postgresql.

如何让客户看向正确的位置?

Fab*_*oni 8

用 检查该--host选项psql --help

然后您可以通过在用户文件中设置它来使其永久化.psqlrc

在你的情况下尝试:

psql -h /var/run/postgresql -d your_database

  • 因此,默认的“主机”值是“本地套接字”,但这并没有告诉我为什么它在 /tmp/ 而不是 /var/run 中查找该套接字 (2认同)