Harsha M V
Harsha M V

Reputation: 54969

Rails - FATAL: database "myapp_development" does not exist

I am trying to set up my Env to use PostgreSQL with Rails and i followed the steps to install PostgreSQL from this Article

Am getting the following error

ATAL: database "myapp_development" does not exist Extracted source (around line #661):

rescue ::PG::Error => error
if error.message.include?("does not exist")
raise ActiveRecord::NoDatabaseError.new(error.message, error)
else
raise
end

Upvotes: 15

Views: 29701

Answers (6)

Tennyson Zvaita
Tennyson Zvaita

Reputation: 9

In my case, the solution was to provide what the error said.."create the database that does not exist"....I spent many hours trying different commands or run db:migrate using bundle but none of that worked. I thought it should create the db on it's own but no...I eventually decided to create the db in postgres

sudo su - postgres
psql
CREATE DATABASE tableNameFromDatabase.yml WITH OWNER myusername;

after this rails db:migrate worked

Upvotes: 0

Arunabh Das
Arunabh Das

Reputation: 14392

Run

rails db:create

before running

rails db:migrate

Upvotes: 5

Salma Gomaa
Salma Gomaa

Reputation: 1112

You can fix it by: bundle exec rake db:setup

Upvotes: 0

shikha
shikha

Reputation: 669

I was having a similar problem. I checked different websites and tried what they suggested but didn't work. Then I tried rake db:create:all and rake db:migrate it worked for me. Thank you!

Upvotes: 1

Kkulikovskis
Kkulikovskis

Reputation: 2088

You can also create PostgreSQL database manually by using psql command prompt.

When in there, connect to your local server and write "create database myapp_development;" without the quotes

Upvotes: 3

scorix
scorix

Reputation: 2516

Did you run rake db:create and rake db:migrate before rails server?

UPDATE

Here's all the steps you should do:

  1. cd /your/app/path
  2. bundle install
  3. bundle exec rake db:create
  4. bundle exec rake db:migrate
  5. bundle exec rails server

Upvotes: 64

Related Questions