gpt4 book ai didi

linux - PostgreSQL psql 未启动

转载 作者:太空宇宙 更新时间:2023-11-04 12:20:42 29 4
gpt4 key购买 nike

我有Debian 9,通过单元文件启动postgresql,在postgresql.conf中监听IP - 服务器IP地址,端口5432,在pg_hba.conf中

# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres trust
#host replication postgres 127.0.0.1/32 trust
#host replication postgres ::1/128 trust

.

$ ls -la /var/run/postgresql/
total 4
drwxrwsr-x 2 postgres postgres 80 Sep 7 19:52 .
drwxr-xr-x 18 root root 560 Sep 7 16:22 ..
srwxrwxrwx 1 postgres postgres 0 Sep 7 19:52 .s.PGSQL.5432
-rw------- 1 postgres postgres 69 Sep 7 19:52 .s.PGSQL.5432.lock

哪里出了问题?

最佳答案

Debian 上的

psql 通过查看以下选项或配置变量来确定它应该连接到哪个 PostgreSQL 实例(或“集群”),如 man pg_wrapper 所述:

The target cluster is selected by the following means, in descending order of precedence:

  1. explicit specification with the --host option

  2. explicit specification with the --cluster option

  3. if the PGHOST environment variable is set, no further cluster selection is performed. The default PostgreSQL version and port number (from the command line, the environment variable PGPORT, or default 5432) will be used.

  4. explicit specification with the PGCLUSTER environment variable

  5. matching entry in ~/.postgresqlrc (see postgresqlrc(5)), if that file exists

  6. matching entry in /etc/postgresql-common/user_clusters (see user_clusters(5)), if that file exists

  7. If only one local cluster exists, that one will be selected.

  8. If several local clusters exist, the one listening on the default port 5432 will be selected.

要弄清楚为什么 psql 选择与 5432 不同的端口,请查看点 #1 到 #7,因为只使用端口 5432是它尝试的最后一件事。

关于linux - PostgreSQL psql 未启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46101834/

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