【问题标题】:psql: error: could not connect to server: No such file or directorypsql:错误:无法连接到服务器:没有这样的文件或目录
【发布时间】:2021-02-22 19:44:30
【问题描述】:

我已经安装了 Postgresql 并且难以配置它,尝试重新安装但仍然遇到问题,我删除了所有文件,然后安装了 postgre 9.6 版本,但出现以下问题。

9.6 main    5432 down   postgres /var/lib/postgresql/9.6/main /var/log/postgresql/postgresql-9.6-main.log

当我尝试使用 sudo -u postgres psql 运行 postgre 时,它​​会给出以下输出

psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

我也尝试过其他问题,但无法解决问题。

【问题讨论】:

    标签: linux postgresql ubuntu-18.04 postgresql-9.6


    【解决方案1】:

    您的 PostgreSQL 客户端很可能配置了与服务器不同的套接字目录 (/var/run/postgresql)。查看postgresql.conf中的unix_socket_directories配置参数。

    服务器可能正在侦听默认目录/tmp。试试

    psql -h /tmp ...
    

    当然也可能是服务器正在侦听不同的端口,例如5555(配置参数port)。然后运行

    psql -p 5555 ...
    

    【讨论】:

      猜你喜欢
      • 2018-01-14
      • 2021-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-29
      相关资源
      最近更新 更多