簡體   English   中英

ruby on rails無法連接到postgres得到PG :: Error:fe_sendauth:沒有密碼

[英]ruby on rails can't connect to postgres got PG::Error: fe_sendauth: no password supplie

我正在嘗試按照此指南在Mac(OS 10.9.4)上運行本地畫布實例: https : //github.com/instructure/canvas-lms/wiki/Quick-Start

在啟動畫布服務器之前,我需要填充數據庫,然后運行:

bundle exec rake db:initial_setup 

但是后來我得到了這個錯誤:

rake aborted!
PG::Error: fe_sendauth: no password supplied
/Users/calvinmwhu/gems/bundler/gems/rails-e86daf8ff727/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:941:in `initialize'
/Users/calvinmwhu/gems/bundler/gems/rails-e86daf8ff727/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:941:in `new'
/Users/calvinmwhu/gems/bundler/gems/rails-e86daf8ff727/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:941:in `connect'
/Users/calvinmwhu/gems/bundler/gems/rails-e86daf8ff727/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:217:in `initialize'

我正在運行ruby 1.9.3p547,而我的database.yml看起來像:

test:
  adapter: postgresql
  encoding: utf8
  database: canvas_test
  host: localhost
  username: postgres
  timeout: 5000

test-in-memory:
 adapter: sqlite3
 encoding: utf8
 database: ':memory:'
 pool: 1

development:
  adapter: postgresql
  encoding: utf8
  database: canvas_development
  timeout: 5000
queue:
   adapter: postgresql
   encoding: utf8
   database: canvas_queue_development
   timeout: 5000

production:
  adapter: postgresql
  encoding: utf8
  database: canvas_production
  host: localhost
  username: postgres
  password: 
  timeout: 5000
queue:
  adapter: postgresql
  encoding: utf8
  database: canvas_queue_production
  host: localhost
  username: postgres
  password: 
  timeout: 5000

我的pg_hba.conf是:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# 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           trust 
#host    replication     postgres        ::1/128                 md5

最后是我在postgres中創建的所有數據庫的列表:

           Name           |  Owner   | Encoding | Collate | Ctype |   Access privileges   
--------------------------+----------+----------+---------+-------+-----------------------
 canvas_development       | postgres | UTF8     | C       | C     | 
 canvas_queue_development | postgres | UTF8     | C       | C     | 
 postgres                 | postgres | UTF8     | C       | C     | 
 template0                | postgres | UTF8     | C       | C     | =c/postgres          +
                          |          |          |         |       | postgres=CTc/postgres
 template1                | postgres | UTF8     | C       | C     | =c/postgres          +
                          |          |          |         |       | postgres=CTc/postgres
(5 rows)

抱歉,我知道有人問過類似的問題。 但是我幾乎嘗試了所有已發布的解決方案,但是都沒有用。 有什么想法嗎? 它強迫我提供密碼,但是我應該在database.yml中輸入密碼(我已經輸入了密碼,但是沒有用)?

謝謝!

pg_hba和postgres用戶有問題。 您正在使用MacOS,因此在本地計算機上,database.yml文件的測試和開發部分下,您應該將用戶名更改為登錄的用戶名(而不是postgres)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM