嘿我想看一个人的示例应用程序。所以我从github上下载并安装了ruby版本,他们使用的是ruby 2.0.0,但是当我尝试$ 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)
知道我应该做什么吗?
的database.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
答案 0 :(得分:2)
要安装postgres,您可以使用以下命令:
sudo apt-get install postgresql-9.1 postgresql-server-dev-9.1
然后你应该为新用户设置密码
sudo passwd postgres
您必须确保config / database.yml中的数据库配置参数(如用户名,密码等)正确无误。 然后:
rake db:setup
将创建数据库并恢复模式(如果有的话)。