加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

macos – 为什么我不能在将其作为服务运行时访问postgres?

发布时间:2020-12-13 16:02:51 所属栏目:百科 来源:网络整理
导读:当我尝试通过webapp访问postgres,或用psql -d template1打开postgres shell时,我收到一个错误. 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.P
当我尝试通过webapp访问postgres,或用psql -d template1打开postgres shell时,我收到一个错误.

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

(*我已经阅读了很多有关此错误的SO主题,但推荐的解决方案并未解决此问题)

将postgres作为服务启动:

brew services restart postgresql

Stopping postgresql… (might take a while)
==> Successfully stopped postgresql (label: homebrew.mxcl.postgresql)
==> Successfully started postgresql (label: homebrew.mxcl.postgresql)

在终端中手动运行postgres:

我可以通过在终端窗口中运行来完成所有工作,但我更喜欢在后台运行它.

postgres -D /usr/local/var/postgres9.6.3

集群:

我在/usr/local/var中有3个数据库集群,但我想使用postgres9.6.3 /

postgres
postgres9.5/
postgres9.6.3/

哪一个:

哪个psql返回/usr/local/bin / psql

路径:

echo $PATH返回/usr/local/bin和/usr/local/var(已添加)

其他推荐解决方案

很多人都可以通过删除/postgres/postmaster.pid来解决这个问题,但这个文件对我来说并不存在.

UPDATE

运行ps -ef | grep postgres,仅输出,

501  2135  1530   0 12:08pm ttys002    0:00.00 grep postgres

使用brew servies重新启动postgres后,/usr/local/var / log中的postgres.log包含,

FATAL:  database files are incompatible with server
DETAIL:  The data directory was initialized by PostgreSQL version 9.5,which is not compatible with this version 9.6.3.

解决方法

如果要将9.5数据与9.6服务器一起使用.你必须运行:

> pg_upgrade(here)或
> pg_dump从9.5到文件和pg_restore | psql取决于9.6上的备份类型…(here)

如果您选择第一个选项,则无需进一步的步骤 – 您的默认版本为9.6,它将与现有数据目录一起使用.

在运行pg_upgrade之前,请复制data_directory

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读