在http://ruby.railstutorial.org/学习3.2 版
卡在 6.2.1 部分的末尾,内容如下:
$ bundle exec rake db:test:prepare
rake aborted!
FATAL: no pg_hba.conf entry for host "192.168.108.1", user "sample_user", database "postgres", SSL on
FATAL: no pg_hba.conf entry for host "192.168.108.1", user "sample_user", database "postgres", SSL off
Tasks: TOP => db:test:load => db:test:purge
192.168.108.1 是我的 ip。如果我在 database.yml 中有另一个条目,它为什么要寻找它?用户 sample_user 是所有数据库的所有者,并在其上拥有 CREATEDB。我可以使用来自 192.168.108.1 的 psql 成功连接到 192.168.108.2 上的任何数据库
我如何克服它,仍在使用远程 postgres?
宝石文件
source 'https://rubygems.org'
gem 'rails', '3.2.3'
gem 'bootstrap-sass', '2.0.0'
gem 'pg', '0.12.2'
group :development, :test do
gem 'rspec-rails', '2.9.0'
end
group :assets do
gem 'sass-rails', '3.2.4'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.0'
group :development do
gem 'annotate', '~> 2.4.1.beta'
end
group :test do
gem 'capybara', '1.1.2'
gem 'spork', '0.9.0'
end
数据库.yml
common: &common
adapter: postgresql
username: sample_user
password: qwerty123
host: 192.168.108.2
development:
<<: *common
database: sample_db_dev
test:
<<: *common
database: sample_db_tst
production:
<<: *common
database: sample_db_pro
pg_hba.conf 在 192.168.108.2
host sample_db_dev sample_user 192.168.108.1/32 md5
host sample_db_tst sample_user 192.168.108.1/32 md5
host sample_db_pro sample_user 192.168.108.1/32 md5
在 192.168.108.1 上没有本地 pg_hba.conf
红宝石 1.9.3p125 Rails 3.2.3 psql (PostgreSQL) 8.4.11