简体   繁体   English

Rails:rake db:create:all(无法连接到服务器)

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

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: 按照截屏视频http://railscasts.com/episodes/342-migrating-to-postgresql?autoplay=true执行 “rake db:create:all”的步骤并获取错误:

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"? 无法连接到服务器:没有这样的文件或目录服务器是否在本地运行并接受Unix域套接字“/tmp/.s.PGSQL.5432”上的连接?

refer the question on Rails: rake db:create:all fails to connect to PostgreSQL database 请参阅Rails上的问题:rake db:create:all无法连接到PostgreSQL数据库

but still unable to resolve it. 但仍然无法解决它。 Not sure what is the problem. 不确定是什么问题。 在此输入图像描述

[database.yml] [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: 

[update2] [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 . unix套接字应该在/var/pgsql_socket (根据plist图像),其中rails试图在/tmp找到套接字文件。 I believe this is the reason for error. 我相信这是错误的原因。 so Edit your database.yml & explicitly add socket location. 所以编辑你的database.yml并显式添加套接字位置。 so your final database.yml should look like this . 所以你的最终database.yml应该是这样的 change the file location for your unix socket location. 更改unix套接字位置的文件位置。 try to connection now? 现在尝试连接?

2) If it still doesn't connect. 2)如果仍然没有连接。 verify that postgres server is actually running 验证postgres服务器实际上是否正在运行

$ netstat -a | grep postgre

if its running, try connecting to it from terminal using psql command. 如果它正在运行,请尝试使用psql命令从终端连接到它。 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? 如果它仍然无法启动,server.log中是否有任何错误消息? If yes do post them here. 如果是,请在此处发布。

Good luck! 祝好运! =======UPDATED=============== =======已更新=============== 在此输入图像描述在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM