Fedora 21 上的 PSQL 9.3 识别身份验证错误



[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 来清理所有内容,但只是不起作用。看起来有什么问题?

无法为 {"适配器"=>"postgresql"创建数据库, "编码"=>"UTF8", "数据库"=>"forum_development", "池"=>5, "用户名"=>"dguedes", "密码"=>"XXXXXXXX", "host"=>"localhost"} 致命:用户"dguedes"的识别身份验证失败

您已经为 IP 地址 localhost 上的所有用户配置了识别配置,如果您不是操作系统用户帐户dguedes您无法以用户 postgresql 用户名dguedes连接到 postgresql。

psql -d forum_development -U dguedes

在这里,您可以通过"本地"接口进行连接("本地"与"本地主机"不同)。本地是一个 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 用户的识别。 它由某些维护任务使用,应重新启用。

相关内容

  • 没有找到相关文章

最新更新