mysql - 无法加载数据库配置。没有这样的文件 - database.yml - OpsWorks

标签 mysql ruby-on-rails git ruby-on-rails-4 aws-opsworks

我是第一次使用 OpsWorks (Ubuntu 14.04) 部署我的应用程序,当迁移运行时我收到此错误:

无法加载数据库配置。没有这样的文件 -/srv/www/todoapp/releases/20150122121517/config/database.yml

我不明白这个错误,因为我的 Rails 应用程序中有一个/config/database.yml 并且被正确地推送到 bitbucket。

你可以在这里看到我的 .gitignore 文件:

# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
#   git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal

# Ignore all logfiles and tempfiles.
/log/*.log
/tmp

最佳答案

我相信 Amazon Opsworks 会覆盖您的 database.yml 文件。您将必须添加自定义 JSON 来配置您的生产数据库。

无论如何,这就是您的 JSON 的样子。

{
  "deploy": {
    "app_short_name": {  # this should be the short name Opsworks has given your app.
      "database": {
        "adapter": "postgresql", # change if you are using mysql
        "encoding": "unicode",
        "host": "your-host",
        "port": "5432", # change if you are using mysql
        "database": "your_database_name",
        "pool": "10",
        "username": "your_database_username",
        "password": "your_database_password"
      }
    }
  }
}

您可以在 Opsworks 堆栈设置中添加它。

  • 登录您的 Opsworks
  • 点击左侧边栏上的Stack
  • 单击堆栈设置按钮。
  • 在底部您会看到配置管理部分。您可以在此处添加自定义 JSON 以正确配置数据库。

以上设置适用于 Postgres 数据库配置。您可能需要使用 mysql 对其进行一些更改。

我使用 Amazon RDS postgres 数据库进行了设置。 RDS还支持mysql。

希望这有助于您离部署应用更近一步。祝你好运。

关于mysql - 无法加载数据库配置。没有这样的文件 - database.yml - OpsWorks,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28092004/

相关文章:

php - 如何以分布式方式将 Zend_cache 与 memcached 一起使用?

ruby-on-rails - 带有 Carrierwave 的动态 uploader

Git 命令获取包含特定文本的文件的所有提交者列表

visual-studio - 用于 git 推送错误的 Microsoft Visual Studio 工具

sql - 将 MS Access 迁移到 MySQL

php + mysql 安全插入数据

ruby-on-rails - Rails Webpacker 图像不会加载,除非通过导入手动定义

ruby-on-rails - 预期响应为 <redirect>,但为 <200> 失败

git - 编写拒绝无效子模块提交的 git update hook 的最佳方法是什么?

MySQL:删除所有早于 20 小时的行