Rails: rake db:create:all (could not connect to server)

筅森魡賤 提交于 2019-12-19 09:24:37

问题


follow the screencasts http://railscasts.com/episodes/342-migrating-to-postgresql?autoplay=true up to the steps of "rake db:create:all" and get error:

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"?

refer the question on Rails: rake db:create:all fails to connect to PostgreSQL database

but still unable to resolve it. Not sure what is the problem.

[database.yml]

development:
  adapter: postgresql
  encoding: unicode
  database: store_development
  pool: 5
  username: amysukumunu 
  password:
test:
  adapter: postgresql
  encoding: unicode
  database: store_test
  pool: 5
  username: amysukumunu
  password: 

回答1:


[update2]

okay, This is what you should do:

  1. the unix socket should be at /var/pgsql_socket(as per the plist image) where as rails is trying to find the socket file in /tmp. I believe this is the reason for error. so Edit your database.yml & explicitly add socket location. so your final database.yml should look like this. change the file location for your unix socket location. try to connection now?

2) If it still doesn't connect. verify that postgres server is actually running

$ netstat -a | grep postgre

if its running, try connecting to it from terminal using psql command. incase its, not running. try starting it manually

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

If it still doesn't start, Are there any error messages in the server.log? If yes do post them here.

Good luck! =======UPDATED===============



来源:https://stackoverflow.com/questions/10482853/rails-rake-dbcreateall-could-not-connect-to-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!