问题描述
我目前正在使用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
文件,如下图所示:
$ 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以获取更多信息