这里描述的所有配置文件都与我的 Mac OS 相同,并且在 Mac OS 中都可以正常工作。
我在 CentOS 6 x86_64 中遇到同样的错误:
Ident authentication failed for user 'abelard'
运行以下两条命令时:
1. rake db:create
2. psql -d testforabelard2 -U abelard -h localhost
我的/var/lib/pgsql/9.4/pg_hba.con
的内容如下:
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
还有一个空白文件/var/lib/pgsql/9.4/pg_ident.con
我的database.yml
的内容如下:
development:
adapter: postgresql
encoding: unicode
database: social_stream_development
pool: 5
username: abelard
password: password
host: localhost
port: 5432
我找到了解决办法:从上面的database.yml
中删除host:localhost
后错误消失。但是我无法删除host:localhost
,因为在使用think-sphinx
进行全文搜索时,会自动生成一个sql_host = localhost
。
为了提供与我的 Mac 操作系统相同的参数,我更改了 PostgreSQL
的用户 abelard
:
testforabelard2=# \du
List of roles
Role name | Attributes | Member of
-----------+-------------+-----------
abelard | Superuser | {}
: Create role
: Create DB
postgres | Superuser | {}
: Create role
: Create DB
而且我可以在没有 -h localhost
的情况下成功运行命令:
psql -d testforabelard2 -U abelard
我不知道我错过了什么,我应该怎么做才能纠正这个错误?欢迎任何建议!
最佳答案
我最终通过将 /var/lib/pgsql/9.4/pg_hba.con
移动到 /var/lib/pgsql/9.4/data/pg_hba.con
轻松解决了自己的问题>.
我犯这个错误的原因是我引用了我的 Mac OS 文件 pg_hba.con
的位置。
当然感谢这个早博“FATAL: IDENT AUTHENTICATION FAILED”, OR HOW COOL IDEAS GET BAD USAGE SCHEMAS ,这让我意识到了上面文件错误的地方!
关于ruby-on-rails - 为什么Cent OS 6、PostgreSQL 9.4和Rails 3.2下database.yml必须删除 "host:localhost",否则报错: Ident authentication failed?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31126624/