bundle exec rake db:创建错误

时间:2016-11-13 04:46:24

标签: ruby-on-rails ruby postgresql

当我运行bundle exec rake db:create

时,请继续这样做
could not connect to server: Connection refused
    Is the server running on host "localhost" (::1) and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused
    Is the server running on host "localhost" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?

任何想法如何解决这个问题?

2 个答案:

答案 0 :(得分:0)

这可能是因为许可问题。导航到/etc/postgresql/<your version of pg>/main/并打开pg_hba.conf。

在那里搜索一句话 local all postgres peer并将其替换为local all all trust。 然后在终端中运行sudo service postgresql restart

答案 1 :(得分:0)

试试这个:

它会起作用

您的database.yml应如下所示:

development:
  adapter: postgresql
  encoding: unicode
  database: <DATABASE_NAME>
  pool: 5
  username: <username>
  password: <password>
  host: localhost
  port: 5432

对于其他环境也是如此