All config files described here are the same as my Mac OS's and all works fine in Mac OS.
I got the same error in CentOS 6 x86_64:
Ident authentication failed for user 'abelard'
When running the following two commands:
1. rake db:create
2. psql -d testforabelard2 -U abelard -h localhost
I got the same error after trying these answers 1 and 2.
My /var/lib/pgsql/9.4/pg_hba.con
's content is as follows:
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
And there is a blank file /var/lib/pgsql/9.4/pg_ident.con
My database.yml
's content is as follows:
development:
adapter: postgresql
encoding: unicode
database: social_stream_development
pool: 5
username: abelard
password: password
host: localhost
port: 5432
I found a resolution: the error disappear after deleting host:localhost
from the above database.yml
. But I can not delete host:localhost
because there is a sql_host = localhost
generated automatically when using think-sphinx
for full-text search.
And for offering the same params as my Mac OS's, I altered PostgreSQL
's user abelard
:
testforabelard2=# \du
List of roles
Role name | Attributes | Member of
-----------+-------------+-----------
abelard | Superuser | {}
: Create role
: Create DB
postgres | Superuser | {}
: Create role
: Create DB
And I can run the command without -h localhost
successfully:
psql -d testforabelard2 -U abelard
I don't know what things I miss, what should I do for correct this error? Any advice will be welcome!