Ruby-on-rails Rails - 致命:数据库“myapp_development”不存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28404482/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 00:04:40  来源:igfitidea点击:

Rails - FATAL: database "myapp_development" does not exist

ruby-on-railspostgresqlruby-on-rails-4

提问by Harsha M V

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

我试图建立我的信封使用PostgreSQL使用Rails,我跟着步骤从这个安装PostgreSQL文章

Am getting the following error

我收到以下错误

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

ATAL:数据库“myapp_development”不存在提取的源代码(围绕第 661 行):

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

回答by scorix

Did you run rake db:createand rake db:migratebefore rails server?

你运行rake db:createrake db:migrate之前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
  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

回答by Arunabh Das

Run

rails db:create

before running

跑步前

rails db:migrate

回答by Kkulikovskis

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

您还可以使用 psql 命令提示符手动创建 PostgreSQL 数据库。

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

在那里,连接到您的本地服务器并编写“创建数据库 myapp_development;” 没有引号

回答by djadam

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:alland rake db:migrateit worked for me. Thank you!

我遇到了类似的问题。我检查了不同的网站并尝试了他们的建议,但没有奏效。然后我尝试 rake db:create:alldb:migrate它对我有用。谢谢!

回答by Salma Gomaa

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

您可以通过以下方式修复它: bundle exec rake db:setup