Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

postgresql - Rails + Postgres fe_sendauth: no password supplied

Hi I'm trying to hook up postgresql to my rails project. I'm learning testing but my tests aren't running because of a postgresql error about having an incorrect password:

Edmunds-MacBook-Pro:langexchange edmundmai$ rake test:units
rake aborted!
fe_sendauth: no password supplied

I've already read around and my pg_hba.conf file was originally already like this:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     edmundmai  

here's my database.yml file in my rails project

default: &default
  adapter: postgresql
  encoding: utf8
  pool: 5
  username: edmundmai
  password: 

development:
  <<: *default
  database: project_development

test:
  <<: *default
  database: project_test

production:
  <<: *default
  database: project_production

Does anyone know how I could fix this? We can chat if it's easier.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Be sure that you have defined both RAILS_ENV and RACK_ENV on your production hosting server. I had a similar issue crop up where everything worked except rake and the solution was to add RACK_ENV=production to my environment. RAILS_ENV was already set to production.

export RACK_ENV=production

bundle exec rake db:version

You should see some output such as:

Current version: 20121126151935

Solution: make sure your Rails app has access to the RAILS_ENV and RACK_ENV environmental variables. Also, ensure they're both the same value.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...