gpt4 book ai didi

postgresql - Psql 无法连接到服务器 : No such file or directory, 5432 错误?

转载 作者:行者123 更新时间:2023-11-29 11:05:31 31 4
gpt4 key购买 nike

我试图在我的 Vagrant 机器上运行 psql,但是我得到这个错误:

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"?

注意:Vagrant 1.9.2盒子:ubuntu/trusty64,https://atlas.hashicorp.com/ubuntu/boxes/trusty64

编辑我用来安装和运行 postgres 的命令:

  • sudo apt-get update
  • sudo apt-get install postgresql
  • sudo su postgres
  • psql -d postgres -U postgres

最佳答案

我遇到过同样的问题,与我的 pg_hba.conf 文件(位于 /etc/postgresql/9.6/main 中)的配置有关。请注意,9.6 是我使用的 postgresql 版本。

错误本身与postgresql配置错误有关,导致服务器在启动前崩溃。

我建议遵循这些说明:

  1. 使用 sudo service postgresql start 证明 postgresql 服务正在运行
  2. 运行 pg_lsclusters从您的终端
  3. 检查你正在运行的集群是什么,输出应该是这样的:

    版本 - 集群端口状态所有者数据目录

    9.6 -------- main -- 5432 在线 postgres/var/lib/postgresql/9.6/main

    Disregard the '---' signs, as they are being used there only for alignment. The important information are the version and the cluster. You can also check whether the server is running or not in the status column.

  4. 从版本和集群中复制信息,然后像这样使用: pg_ctlcluster <version> <cluster> start ,所以在我的例子中,使用版本 9.6 和集群“main”,它将是 pg_ctlcluster 9.6 main start
  5. 如果出现问题,postgresql 将生成一个日志,可以在 /var/log/postgresql/postgresql-<version>-main.log 上访问该日志,所以在我的例子中,完整的命令是 sudo nano /var/log/postgresql/postgresql-9.6-main.log .
  6. 输出应该显示错误是什么。

    2017-07-13 16:53:04 BRT [32176-1] LOG: invalid authentication method "all"
    2017-07-13 16:53:04 BRT [32176-2] CONTEXT: line 90 of configuration file "/etc/postgresql/9.5/main/pg_hba.conf"
    2017-07-13 16:53:04 BRT [32176-3] FATAL: could not load pg_hba.conf

  7. 通过sudo service postgresql restart修复错误并重启postgresql服务应该没问题。

我搜索了很多才找到这个,归功于这个 post .

祝你好运!

关于postgresql - Psql 无法连接到服务器 : No such file or directory, 5432 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42653690/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com