我一直在关注Heroku的指南,开始使用Ruby on Heroku,并且试图连接到postgres数据库时遇到困难。
当我跑步时:
bundle exec rake db:create db:migrate
我留下了这个错误:
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
并且:
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"garrett", "username"=>"ruby-getting-started"}
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
我已经尝试编辑我的database.yml文件,但我不确定我是否要更改正确的参数:
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5
development:
<<: *default
database: ruby-getting-started_development
username: ruby-getting-started
test:
<<: *default
database: ruby-getting-started_test
production:
<<: *default
database: ruby-getting-started_production
username: ruby-getting-started
password: <%= ENV['RUBY-GETTING-STARTED_DATABASE_PASSWORD'] %>
我的database.yml设置不正确还是我完全错了?
答案 0 :(得分:1)
这是一个常见的Postgres错误,基本上告诉你它无法找到服务器。这可能是由于各种原因造成的,因为没有安装到OS更新的损坏路径。
如果您确实安装了服务器,可以通过Homebrew或postgres.org上的GUI窗口安装程序重新安装。
无论哪种方式,最快的解决方法是使用单个软件包安装程序,如Postgres.app for mac。