0

I am attempting to create a database for a Rails application and I get the following error message ActiveRecord::NoDatabaseError: FATAL: role "jonathanreiser" does not exist. I am running Postgres 9.6 on OS X El Capitan, Version 10.11.15.

I saw there were similar questions on StackOverflow, but I tried implementing their answers with no success. For example, sudo -u postgres createuser jonathanreiser or sudo su - postgres does not work. Any help would be appreciated.

2
  • What's the error (or output) you get when you execute createuser? Have you tried using also the --pwprompt or --interactive options? Commented Jan 30, 2017 at 7:38
  • The error I get when executing createuser is sudo: unknown user: postgres. I haven't used --pwprompt or --interactive options, how would I go about doing that? Also, what username are we referring to here? Is it the username that I sign onto my macbook with? Commented Jan 30, 2017 at 16:03

2 Answers 2

2

Configure database.yml with below code:

default: &default

adapter: postgresql
  pool: 5
  timeout: 5000
  username : username //pg username
  password : password //pg password

development:
  <<: *default
  database: db_name

test:
  <<: *default
  database: db_name

production:
  <<: *default
  database: db_name

then run command to create database:

rake db:create
Sign up to request clarification or add additional context in comments.

2 Comments

This did not work for me. Question though, what is the database name I should be referring to? Is it the name of one of the tables in my migration files, or is it from someplace else? Also, is the username the name I sign on to my macbook with?
In database name, you can write any name for database. In username, when you install postgres and create user that name is the username.
1

Run

rails db:create

or

rake db:create

Then you can run rails db:migrate

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.