0

[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 以清理所有内容,但没有奏效。什么看起来不对劲?

4

1 回答 1

0

无法为 {"adapter"=>"postgresql"、"encoding"=>"UTF8"、"database"=>"forum_development"、"pool"=>5、"username"=>"dguedes" 创建数据库, “密码”=>“XXXXXXX”,“主机”=>“本地主机”} 致命:用户“dguedes”的身份验证失败

您已为 IP 地址 localhost 上的所有用户配置了 ident 配置,这意味着如果您不是操作系统用户帐户dguedes,则无法以用户 postgresql username 连接到 postgresql dguedes

psql -d forum_development -U dguedes

在这里,您通过“本地”接口连接(“本地”与“本地主机”不同)。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。它被一些维护任务使用,应该重新启用。

于 2015-02-02T04:19:26.427 回答