Ruby on rails rake db:migrate无法连接到服务器错误
嘿,我想看看某人的示例应用程序。因此,我从github下载了它并安装了ruby版本,他们使用的是ruby 2.0.0,但当我尝试执行Ruby on rails rake db:migrate无法连接到服务器错误,ruby-on-rails,Ruby On Rails,嘿,我想看看某人的示例应用程序。因此,我从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
$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
要安装postgres,您可以使用以下命令:
sudo apt-get install postgresql-9.1 postgresql-server-dev-9.1
然后您应该为新用户设置密码
sudo passwd postgres
必须确保config/database.yml中的数据库配置参数(如用户名、密码等)正确无误。
然后:
rake db:setup
将创建数据库并还原架构(如果有)。您的电脑中是否安装了postgresql?否,请回答此问题,以便我可以检查它,但无需:)rake db:setup FATAL:用户“alain”的密码身份验证失败FATAL:用户“alain”的密码身份验证失败你能粘贴你的database.yml文件吗?试着用posgres作为你创建的用户名和密码。注意!这只是为了发展。