我试图将一个rails应用程序上传到heroku,我遇到了将我的应用程序从sqlite3更改为postgres的问题,主要是当我运行rake db:create
时,我得到了:
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
pool: 5
timeout: 5000
development:
<<: *default
database: anagram_development
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: anagram_test
production:
<<: *default
database: anagram_production
答案 0 :(得分:0)
您是否在本地安装了postgresql?如果是这样,请仔细检查它是否正在运行。您的database.yml文件也缺少连接到postgres数据库的一些必需信息。您需要提供用户名,密码和主机名。
这是我的一个连接到本地postgres db的例子:
development:
adapter: postgresql
encoding: unicode
database: app_development
pool: 10
username: <%= %x(whoami) %>
password:
对于heroku / production,您可以使用以下内容:
production:
url: <%= ENV['DATABASE_URL'] %>
pool: <%= ENV['DB_POOL'] || 10 %>