4

When i run rails db i get the below error. psql: FATAL: role "ubuntu" does not exist

First i want to know the exact meaning of what it says before solving it. I have tried http://stackoverflow.com/questions/11919391/postgresql-error-fatal-role-username-does-not-exist this link as well but nothing seems to workout for me ..

Rahul Dess
  • 2,397
  • 2
  • 21
  • 42

1 Answers1

4

I don't have a Rails-specific answer for you, but I can tell you some possibly helpful facts about PostgreSQL authentication:

  1. PostgreSQL uses the term "role" to mean "user" or "login", so the error message means you are trying to connect to the PostgreSQL database with a username of ubuntu, but no such user exists.

  2. If you don't explicitly tell PostgreSQL what user you want to log in as, it will use your operating system credentials. That is, if you're logged in to Linux as the user ubuntu, PostgreSQL will try to log you in as a PostgreSQL user named ubuntu.

  3. PostgreSQL authentication is configured in a file called pg_hba.conf. See http://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html. However, if you're using Rails, I suspect there's a way for you to control the PostgreSQL authentication setup without editing the pg_hba.conf file manually.

Craig Ringer
  • 307,061
  • 76
  • 688
  • 778
Steve Saporta
  • 4,581
  • 3
  • 30
  • 32
  • `pg_hba.conf` is only part of the authentication configuration. Users and passwords are configured at the SQL level. – Craig Ringer Jul 13 '14 at 16:53