2014-02-25 2 views
0

필자는 Rails 애플리케이션 용 PostgreSQL을 사용합니다. pgAdmin와 콘솔을 통해 PostgreSQL 서버에위한 인증이 성공,하지만 난 레일 응용 프로그램을 실행할 때 다음과 같은 오류 얻을 :PostgreSQL 사용자 인증 오류

FATAL: Peer authentication failed for user "postgres" 

database.yml :

development: 
    adapter: postgresql 
    encoding: unicode 
    database: app_dating 
    pool: 5 
    timeout: 5000 
    username: postgres 
    password: '123456' 

pg_hba.conf :

# "local" is for Unix domain socket connections only 
local all    all          md5 
# IPv4 local connections: 
host all    all    127.0.0.1/32   md5 
# IPv6 local connections: 
host all    all    ::1/128     md5 

나는 Rails 4.0.1과 PotgreSQL 9.1을 사용한다.

+0

http://stackoverflow.com/questions/2942485/psql-fatal-ident-authentication-failed-for-user-postgres – Santhosh

답변

2

게시 한 pg_hba.conf이 완료되지 않은 것처럼 보입니다. 당신은 아마 (가기 아마 조금 더) 거기에 이와 유사한 다른 항목이 있습니다

# Database administrative login by Unix domain socket 
local all    postgres        peer 

포스트그레스 documentation for the pg_hba.conf 상태에 대한 피어 인증 :

peer
Obtain the client's operating system user name from the operating system and check if it matches the requested database user name. This is only available for local connections. See Section 19.3.7 for details.

는 따라서, 당신은 확인해야, 이 구성으로 로컬 유닉스 소켓 (TCP 연결 아님)을 사용한다는 것입니다. 또한 Postgres 데이터베이스에 postgres 사용자가 있어야합니다.

다른 방법으로 정의 된 다른 메커니즘으로 대체하려면 pg_hba.conf에서 해당 줄을 제거하는 것입니다. 사용자의 postgres 사용자가 올바른 비밀번호를 설정했는지 확인하십시오.

권한 검사없이 모든 권한을 가진 postgres이라는 사전 정의 된 수퍼 유저를 가지는 것이 일반적입니다. 해당 사용자를 애플리케이션 (예 : Rails 앱)에 사용하는 것은 현명하지 않습니다. 대신 Postgres 데이터베이스에 새로운 사용자를 만들어 앱에 사용하십시오.