gpt4 book ai didi

ruby-on-rails - PostgreSQL 版本 13 psql : error: could not connect to server: could not connect to server: No such file or directory

转载 作者:行者123 更新时间:2023-12-05 03:48:00 30 4
gpt4 key购买 nike

我目前正在使用 Rails 6 应用程序和 Postgresql。我在运行 rails db:create 时遇到问题。这个错误似乎发生在我更新 brew upgrade 我收到以下错误:

rails aborted!
PG::ConnectionBad: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?

我正在运行 Mac OS Mojave,并将 postgresq 更新到版本 13。

$ postgres --version
postgres (PostgreSQL) 13.0

我猜这就是我遇到问题的原因,我在其他一些帖子中注意到运行 brew postgresql-upgrade-database 可能是解决这个问题的方法,但是当我运行我得到的命令:

$ brew postgresql-upgrade-database
Error: No such file or directory @ rb_sysopen - /usr/local/var/postgres/PG_VERSION

但是当我导航到 postgres 时,我可以看到 .old 文件,如下图所示: enter image description here

此外,如果我尝试连接到 psql,我会收到错误

$ psql
psql: error: could not connect to server: 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"?

我还看到该服务正在运行:

$ ps -ef | grep postgres
501 48733 5971 0 1:23PM ttys011 0:00.31 /usr/local/Cellar/macvim/8.2-166_1/MacVim.app/Contents/MacOS/Vim /usr/local/var/postgres/
501 52975 5971 0 1:54PM ttys011 0:00.01 grep postgres

可能是什么问题?

最佳答案

这对我来说已经解决了

initdb `brew --prefix`/var/postgres/data -E utf8

然后运行

pg_ctl -D /usr/local/var/postgres/data -l logfile start

关注PostgreSQL with Homebrew on Mac更多详情

关于ruby-on-rails - PostgreSQL 版本 13 psql : error: could not connect to server: could not connect to server: No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64624791/

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