4

I'm using Rails 3.0 and PostgreSQL 8.4 on Ubuntu 10.10 and Ruby 1.9.2p136 with the pg gem. When I run rake db:migrate, I get the error FATAL: password authentication failed for user "my_os_user_account", when I actually expected it to log in to the database as my_db_username specified in database.yml.

I have md5 authentication configured in pg_hba.conf for both Unix socket and IP connections and I can log in using psql on the command line. I have also tried setting the authentication to trust. psql then allows me to log in without entering a password, but Rails then gives FATAL: role "my_os_user_account" does not exist.

Here's database.yml:

development:
  adapter: postgresql
  database: my_project_dev
  user: my_db_username
  password: my_password
  pool: 5
  timeout: 5000

with additional near-identical entries for test and production.

2 Answers 2

11

The correct key for username is, in fact, username and not user. Easy mistake, easy fix.

Sign up to request clarification or add additional context in comments.

1 Comment

I love it when it's easy! I don't know why I didn't spot that.
1

I had a similar problem. However, my issue was brackets around the actual username and passowrd in database.yml like this "[admin]... [passowrd]", this works for ruby 1.8.7, but not newer versions. Spent an entire aggravating day on this. I realized that might be it after reading this article. (shrug) Hope this helps someone else.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.