【问题标题】:'development' database is not configured“开发”数据库未配置
【发布时间】:2023-04-02 23:27:01
【问题描述】:

我在对新克隆的应用程序执行 rake db:migrate 时遇到此错误。

'development' 数据库未配置。可用:[“生产”]

所以看了错误之后,我在做RAILS_ENV=production rake db:migrate

但这也不起作用。

我的database.yml 有

production:
adapter: postgresql
encoding: unicode
database: test
pool: 5
username: admin
password: admin
port: 5433

请提出建议。

【问题讨论】:

  • 这不是有效的 yaml。 yaml 需要缩进 2 个空格。

标签: ruby-on-rails ruby rake


【解决方案1】:

添加

development:
  adapter: postgresql
  encoding: unicode
  database: test
  pool: 5
  username: admin
  password: admin
  port: 5433
  host: localhost

到database.yml 文件。

另外,如果您测试您的应用程序,您还需要test 环境。

【讨论】:

  • 耙子中止! PG::ConnectionBad: 无法连接到服务器:没有这样的文件或目录这就是我得到的。
  • 已经尝试添加本地主机。 rake aborted! PG::ConnectionBad: could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5433? could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5433? 错误。
【解决方案2】:

您的database.yml 文件显示您只为数据库操作配置了生产环境。您还需要为开发环境添加配置。

打开您的database.yml 文件并为开发环境添加配置。 如下内容就足够了(方括号中的内容将替换为您的实际值):

development:
    adapter:[your adapter]
    encoding: [your encoding]
    database: [your database for development]
    pool: [your pool]
    username: [your database server username]
    password: [your database server password]
    port: [the port you're connecting on]

记得适当缩进你的 yaml 代码。

【讨论】:

    猜你喜欢
    • 2011-10-11
    • 1970-01-01
    • 2016-07-27
    • 2017-05-04
    • 2018-11-07
    • 1970-01-01
    • 1970-01-01
    • 2020-09-05
    • 1970-01-01
    相关资源
    最近更新 更多