2017-06-20 50 views
-1

我一直对如何从终端执行rake数据库操作感到困惑。它是否通过导轨,然后更改数据库?或者它通过你的计算机上的一些环境变量来查找数据库,然后进行更改?请问rails服务器是否需要运行rake db:actions?

我问这是因为我想运行bundle exec rake db:drop但我不断收到

could not connect to server: Connection refused 
Is the server running on host "localhost" (::1) and accepting 
TCP/IP connections on port 5432? 

即使我bundle exec rails s正确连接到我的服务器。

+1

(这应该与数据库用户名和密码一致),我认为这是谈论你的数据库服务器拒绝合作nnection ... –

+0

我该如何检查? – stackjlei

+1

https://www.google.com/search?q=could+not+connect+to+server%3A+Connection+refused&ie=utf-8&oe=utf-8 –

回答

1

您可以运行与导轨服务器rake db命令运行

错误表示没有连接与数据库和解决方案是要么重新启动数据库服务器 发生(如果它的Postgres)

sudo service postgres restart 

或可能是你在database.yml文件中提供错误的用户名和密码

+0

如果这有帮助和相关,您可以接受答案:-) – U56987