2

嘿,我想看看某人的示例应用程序。所以我从 github 上下载了它并安装了他们使用 ruby​​ 2.0.0 的 ruby​​ 版本,但是当我尝试这样做时,$ rake db:migrate我得到了这个错误:

rake db:migrate
rake aborted!
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?

/home/alain/.rvm/gems/ruby-2.0.0-preview2/gems/activerecord-4.0.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:796:in `initialize'
/home/alain/.rvm/gems/ruby-2.0.0-preview2/gems/activerecord-4.0.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:796:in `new'
...(etc)

知道我应该怎么做吗?

数据库.yml

development:
  adapter: postgresql
  host: localhost
  encoding: unicode
  database: rentmybike_dev
  pool: 5
  username: alain
  password: obama

test:
  adapter: postgresql
  encoding: unicode
  database: rentmybike_test
  pool: 5

# Add the below...

production:
  adapter: postgresql
  host: localhost
  encoding: unicode
  database: rentmybike_production
  pool: 5
  username: alain
  password: obama
4

1 回答 1

2

要安装 postgres,您可以使用以下命令:

sudo apt-get install postgresql-9.1 postgresql-server-dev-9.1

然后你应该为新用户设置密码

sudo passwd postgres

您必须确保 config/database.yml 中的数据库配置参数(如用户名、密码等)正确。进而:

rake db:setup

将创建数据库并恢复模式(如果有)。

于 2013-07-25T02:54:35.840 回答