【发布时间】:2018-11-18 07:12:00
【问题描述】:
我正在运行 CentOS 7.5,无法设置 PostgreSQL。
如果我以用户 postgres 的身份登录并输入 psql postgres,我会收到以下错误消息:
psql: Could not connect to server: no such file or directory
does the server run locally and accepts connections on Unix-Domain-Socket "/var/run/postgresql/.s.PGSQL.5432"
但是,我将端口更改为 5543(在etc/systemd/system/postgresql.service 中通过将/lib/systemd/system/postgresql.service 包含为[服务] 并设置Environment=PGPORT=5543)。请注意,您不应直接在 /lib/ 中更改它,因为这会被覆盖。
所以,服务器查找错误的 UNIX-Domain-Socket 并没有找到(因为它不存在),但是根据sudo netstat -nlp,正确端口5543 的套接字确实存在:
5486/postgres /var/run/postgresql/.s.PGSQL.5543
postgresql.service 正在根据systemctl status postgresql.service 运行
感谢任何建设性的帮助。
【问题讨论】:
-
如果我将端口恢复为默认的“5432”,它将工作并且我可以连接。但是,坚持使用默认端口并不安全。
-
那么,您更喜欢“默默无闻的安全性”?
-
如果你想说,是的。公平地说 - OP 中提供的端口只是用于解释的虚拟,因为根据经验,您可以信任任何人。但是,一方面保护东西不仅会使它们变硬,另一方面也会使它们更难使用。
标签: postgresql centos