0

I installed postgresql9.1 into my Centos 6.4. I can do psql template (as root) to open the database console but cannot use Rails rake db:create to create the database: FATAL: Ident authentication failed for user "root"

My configuration is as follow:

{
"adapter"=>"postgresql", 
"host"=>"localhost", 
"encoding"=>"unicode", 
"username"=>"root", 
"pool"=>5, 
"database"=>"xxx_prod"
}

I guess Rails is unable to locate the sock file (.s.PGSQL.5432). So I would like to specify it explicitly but I don't know where the sock file is located. Where should it be? How can I locate it?

Phuong Nguyen
  • 703
  • 1
  • 12
  • 27

1 Answers1

2

The problem is not the sock file, but the (very bad in my opinion) decision to make "ident" default authentication scheme.

Locate pg_hba.conf file and change "ident" into "trust" or "md5".

If you want to know more - consider reading this blogpost.

  • Please add the relevant contents instead of self-promoting your blog without disclosure. – Deer Hunter Jun 21 '13 at 11:31
  • After reading some of your posts, I am convinced of their value to the community; if you copy the relevant contents into the answer, you will remove a single-point-of-failure if your blog goes down. (Yes, there's also the Wayback Machine, but we shouldn't rely on it either). – Deer Hunter Jun 21 '13 at 11:37
  • What about - when SO will go down? My blog is online longer than SO. The relevant part is already in answer - find pg_hba.conf, and change authentication scheme. –  Jun 21 '13 at 11:55
  • So when I do `psql template1`, what kind of authentication is being used? – Phuong Nguyen Jun 22 '13 at 04:44
  • We can't know. You have to check in your pg_hba.conf file. –  Jun 22 '13 at 09:22