簡體   English   中英

Fedora 21上的PSQL 9.3身份驗證錯誤

[英]PSQL 9.3 ident authentication error on Fedora 21

[PSGQL 9.3,Fedora 21,Rails 4.2.0]

當我運行任何rails db命令(rake db:migrate,rake db:create等)時,會發生此錯誤:

[dguedes@localhost clean_forum]$ rake db:create
FATAL:  Ident authentication failed for user "dguedes"
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:436:in `new_connection'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:446:in `checkout_new_connection'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:565:in `retrieve_connection'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:87:in `connection'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/postgresql_database_tasks.rb:8:in `connection'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/postgresql_database_tasks.rb:17:in `create'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:93:in `create'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:107:in `block in create_current'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:275:in `block in each_current_configuration'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:274:in `each'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:274:in `each_current_configuration'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:106:in `create_current'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/railties/databases.rake:17:in `block (2 levels) in <top (required)>'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/home/dguedes/.rvm/rubies/ruby-2.2.0/bin/rake:33:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"UTF8", "database"=>"forum_development", "pool"=>5, "username"=>"dguedes", "password"=>"randompass", "host"=>"localhost"}
FATAL:  Ident authentication failed for user "dguedes"
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:436:in `new_connection'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:446:in `checkout_new_connection'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:565:in `retrieve_connection'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:87:in `connection'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/postgresql_database_tasks.rb:8:in `connection'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/postgresql_database_tasks.rb:17:in `create'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:93:in `create'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:107:in `block in create_current'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:275:in `block in each_current_configuration'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:274:in `each'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:274:in `each_current_configuration'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:106:in `create_current'
/home/dguedes/.rvm/gems/ruby-2.2.0@rails4.2.0/gems/activerecord-4.2.0/lib/active_record/railties/databases.rake:17:in `block (2 levels) in <top (required)>'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/home/dguedes/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/home/dguedes/.rvm/rubies/ruby-2.2.0/bin/rake:33:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "database"=>"forum_test", "pool"=>5, "username"=>"dguedes", "password"=>"randompass", "host"=>"localhost"}

在postgres中,我已經使用正確的密碼創建了角色'dguedes',並授予了所有特權。 例如:

bash-4.3$ psql -d forum_development -U dguedes
could not change directory to "/home/dguedes/Desktop/forum/clean_forum": Permission denied
Password for user dguedes: 
psql (9.3.5)
Type "help" for help.

forum_development=# \du
                             List of roles
 Role name |                   Attributes                   | Member of 
-----------+------------------------------------------------+-----------
 dguedes   | Superuser, Create role, Create DB, Replication | {}
 postgres  | Superuser, Create role, Create DB, Replication | {}

forum_development=# 

這表明我的角色已經擁有所有權限。

我的ph_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            ident
# IPv6 local connections:
host    all             all             ::1/128                 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                md5
#host    replication     postgres        127.0.0.1/32            ident
#host    replication     postgres        ::1/128                 ident

我使用命令“ systemctl stop postgresql-9.3”和“ systemctl start postgresql-9.3”重新啟動了服務器,但是沒有任何反應。

最后是我的“ database.yml”文件:

development:
  adapter: postgresql
  encoding: UTF8
  database: forum_development
  pool: 5
  username: dguedes
  password: randompass
  host: localhost

test:
  adapter: postgresql
  encoding: unicode
  database: forum_test
  pool: 5
  username: dguedes
  password: randompass
  host: localhost

因此,我無法解決問題。 我已經嘗試過重新安裝postgre來清理所有東西,但是沒有用。 看起來怎么了?

無法為{“ adapter” =>“ postgresql”,“ encoding” =>“ UTF8”,“ database” =>“ forum_development”,“ pool” => 5,“ username” =>“ dguedes”創建數據庫, “ password” =>“ XXXXXXX”,“ host” =>“ localhost”}致命:用戶“ dguedes”的身份驗證失敗

您可以配置為所有用戶對IP地址的本地主機此meaus如果你不是操作系統用戶戶頭的ident配置dguedes您無法連接到PostgreSQL作為用戶的PostgreSQL用戶名dguedes

psql -d forum_development -U dguedes

在這里,您通過“本地”接口進行連接(“本地”與“ localhost”不同)。 Local是一個Unix域套接字 (地址/var/run/postgresql/5432或類似的名稱),該接口對所有用戶都具有md5身份驗證,因此,任何想作為dguedes連接的人都需要輸入密碼。

如果要在應用程序中使用此接口,則連接參數字符串不應指定主機:

 {"adapter"=>"postgresql", "encoding"=>"UTF8", "database"=>"forum_development",
  "pool"=>5, "username"=>"dguedes", "password"=>"XXXXXXX" }

或者可以選擇將主機顯式指定為空或NULL。

  ,"host"=>""

我看到另外兩個問題。

您在上面的日志文件中公開了密碼,因此現在是更改密碼的好時機。

在pg_hba.conf中禁用了本地postgres用戶的ident。 由某些維護任務使用,應重新啟用。

暫無
暫無

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

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