rake db:create抛出“数据库不存在” PostgreSQL错误

编程入门 行业动态 更新时间:2024-10-19 08:43:45
本文介绍了rake db:create抛出“数据库不存在” PostgreSQL错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在Debian 7下将Rails 4.1.5与Postgresql 9.1一起使用,但无法在开发环境中创建数据库。当我运行

I'm using rails 4.1.5 with postgresql 9.1 under Debian 7, and I'm not able to create a database in my development environment. When I run

bin/rake db:create

我得到

home/rs/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql_adapter.rb:898:in `rescue in connect': FATAL: database "direct-dev" does not exist Run `$ bin/rake db:create db:migrate` to create your database (ActiveRecord::NoDatabaseError) from /home/rs/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `connect' from ...

我试图创建数据库,所以自然不存在。但是rails应该创建它...这是我的config / database.yml:

I am trying to create the database so, naturally, it does not exist. However rails should create it ... Here's my config/database.yml:

default: &default adapter: postgresql encoding: unicode pool: 5 development: <<: *default database: direct-dev

这是postgresql日志的一部分:

And here's a part of the postgresql log:

2014-09-01 19:30:40 CEST LOG: connection received: host=[local] 2014-09-01 19:30:40 CEST LOG: connection authorized: user=rs database=direct-dev 2014-09-01 19:30:40 CEST FATAL: database "direct-dev" does not exist

您有指针吗?我已经在这里待了一个多小时,但仍然不明白为什么会这样...

Do you have any pointers? I've been at this for more than an hour, and still can't understand why this is happening ...

谢谢!

推荐答案

Rails 4.1 带有spring preloader的船和

Rails 4.1 ships with spring preloader, and

New Rails 4.1应用程序将附带弹簧化的binstub。这意味着bin / rails和bin / rake将自动利用预加载的弹簧环境。

New Rails 4.1 applications will ship with "springified" binstubs. This means that bin/rails and bin/rake will automatically take advantage of preloaded spring environments.

这意味着弹簧化 bin / rake 将尝试预加载该应用程序,而该应用程序又将尝试运行初始化程序,从而导致您遇到的问题。

which means that the "springified" bin/rake will attempt to preload the app, which in turn will attempt to run the initilizers resulting in the problem you're seeing.

要解决/解决此问题,您需要在没有弹簧的情况下运行初始设置耙任务。实现此目标的一种方法是使用捆绑程序运行它:

To fix / work around this you want to run the initial setup rake tasks without spring. One way to achieve that is to run it with bundler instead:

bundle exec rake db:create

更多推荐

rake db:create抛出“数据库不存在” PostgreSQL错误

本文发布于:2023-10-15 03:06:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1493061.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不存在   抛出   错误   数据库   db

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!