Rails: rake db:create:all (could not connect to se

2020-03-26 03:40发布

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. enter image description here

[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条回答
倾城 Initia
2楼-- · 2020-03-26 04:27

[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=============== enter image description here enter image description here

查看更多
登录 后发表回答