0

While running the command rake db:create, the system throws postgresql authentication fails

FATAL:  password authentication failed for user "postgres"
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "username"=>"postgres", "password"=>"password", "timeout"=>5000, "host"=>"localhost", "database"=>"rails-sample-guestbook-master_development"}
rake aborted!

database.yml file

default: &default
  adapter: postgresql
  encoding: unicode
  pool: 5
  username: supranimbus
  password: 123456789
  timeout: 5000
  host: localhost
development:
  <<: *default
  database: rails-sample-guestbook-master_development

test:
  <<: *default
  database: rails-sample-guestbook-master_test

production:
  <<: *default
  database: rails-sample-guestbook-master_production
ArtOfCode
  • 5,702
  • 5
  • 37
  • 56
Dhinakaran
  • 815
  • 2
  • 7
  • 15
  • you could check your password settings in your config file (`database.yml`), is your password really `password` only word? – Hatik Jan 11 '18 at 10:36
  • 1
    Please share your `database.yml` – Aakanksha Jan 11 '18 at 10:37
  • 1
    Find out if you configured your postgres database properly. – Marek Lipka Jan 11 '18 at 10:37
  • How is your database configured? How is your rails application configured? You haven't shared *either* of these things with us, so it's impossible to answer the question... But *almost certainly*, the issue is that those two configurations do not match. – Tom Lord Jan 11 '18 at 10:45
  • default: &default adapter: postgresql encoding: unicode pool: 5 username: supranimbus password: 123456789 timeout: 5000 host: localhost development: <<: *default database: rails-sample-guestbook-master_development # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default database: rails-sample-guestbook-master_test production: <<: *default database: rails-sample-guestbook-master_production – Dhinakaran Jan 11 '18 at 10:54
  • Can you check if you have a user in postgres with username and password as mentioned in question? – Aakanksha Jan 11 '18 at 16:57
  • yeah, I have mentioned postgres username and password – Dhinakaran Jan 12 '18 at 04:34
  • Possible duplicate of [PG::ConnectionBad: FATAL: password authentication failed for user "alphauser"](https://stackoverflow.com/questions/28793606/pgconnectionbad-fatal-password-authentication-failed-for-user-alphauser) – vich Jan 12 '18 at 22:14

1 Answers1

1

I guess the problem is setup password on postgresql if you don't remember the default password then go to pgAdmin click to open dashboard and then the left sidebar see the below image

enter image description here

Click the Properties... then will open a modal like see the below image

enter image description here

and click the Definition tab and see the Password field and set the new password, remember this password for postgres username.

That's is for password setup!

Now update your database.yml file like below

default: &default
  adapter: postgresql
  encoding: unicode
  username: postgres
  password: 123456 #=> which you set for postgres
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
  <<: *default
  database: project_development

Hope to help

fool-dev
  • 7,671
  • 9
  • 40
  • 54