PostgreSQL版本13 psql:错误:无法连接到服务器:无法连接到服务器:没有这样的文件或目录

问题描述

我目前正在使用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

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

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

问题可能是什么?

解决方法

这为我解决了

ellipse_box = [55,37,107 + 48 + 46,103 + 80]
draw_ellipse(im,ellipse_box,width=20,outline=(52,235,52))

然后运行

$bdd = new PDO('mysql:host=127.0.0.1;dbname=fireblock','root','');

关注PostgreSQL with Homebrew on Mac以获取更多信息

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...