【发布时间】:2013-08-02 13:08:09
【问题描述】:
数据库.yml:
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: postgresql
encoding: utf8
database: sampleapp_dev #can be anything unique
#host: localhost
#username: 7stud
#password:
#adapter: sqlite3
#database: db/development.sqlite3
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: postgresql
encoding: utf8
database: sampleapp_test #can be anything unique
#host: localhost
#username: 7stud
#password:
#adapter: sqlite3
#database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: postgresql
database: sampleapp_prod #can be anything unique
#host: localhost
#username: 7stud
#password:
#adapter: sqlite3
#database: db/production.sqlite3
pool: 5
timeout: 5000
pg_hba.conf:
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres md5
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
我将前三行中的 METHOD 从 md5 更改为 trust,但我仍然收到错误。
无论我在 database.yml 中尝试什么组合,当我这样做时:
~/rails_projects/sample_app4_0$ bundle exec rake db:create:all
我总是得到错误:
fe_sendauth:未提供密码
我按照本教程进行设置:
https://pragtob.wordpress.com/2012/09/12/setting-up-postgresql-for-ruby-on-rails-on-linux
Mac OSX 10.6.8
PostgreSQL 9.2.4 installed via enterpriseDB installer
Install dir: /Library/PostgreSQL/9.2
【问题讨论】:
-
您在进行更改后重新加载了 pg_hba.conf 文件?
-
@bma,你如何重新加载它?我能够连接到服务器的唯一方法是使用 pgAdmin3(在 9.2 目录中)。我选择服务器,右键单击,然后选择连接。因此,为了尝试重新加载 conf 文件,我在 pgAdmin3 中断开了与服务器的连接,然后重新连接。
-
您可以发出查询:
select pg_reload_conf()作为超级用户,或者在 pgadmin 中您可以右键单击数据库名称,然后单击“重新加载配置”(我认为这就是这样做的,我不知道t 使用 pgadmin) -
@bma, !$#@%!$^%!那行得通。你能把你的cmets放在一个答案中吗?
-
我遇到了同样的问题。我解决了将用户名:postgres 和密码:放入我的 database.yml
标签: postgresql ruby-on-rails-4