【问题标题】:Unable to connect aws rds using Sailsjs adapters无法使用 Sailsjs 适配器连接 aws rds
【发布时间】:2016-09-24 04:26:12
【问题描述】:

我能够从 mysql CLI 访问我的 aws rds mysql 实例。但是相同的配置不适用于sailsjs 数据库适配器。

这是我的 ./config/env/production.js

connections: {
    mysqlServer: {
      host: "demo.c4a1v1iyi4x1.ap-southeast-1.rds.amazonaws.com",
      user: "username",
      password: "password",
      database: "mydb",
    },
  }, 

我已经修改了我的 ./config/models.js 来创建表格

/**
 * Default model configuration
 * (sails.config.models)
 *
 * Unless you override them, the following properties will be included
 * in each of your models.
 *
 * For more info on Sails models, see:
 * http://sailsjs.org/#/documentation/concepts/ORM
 */

module.exports.models = {

  /***************************************************************************
  *                                                                          *
  * Your app's default connection. i.e. the name of one of your app's        *
  * connections (see `config/connections.js`)                                *
  *                                                                          *
  ***************************************************************************/
  connection: 'mysqlServer',

  /***************************************************************************
  *                                                                          *
  * How and whether Sails will attempt to automatically rebuild the          *
  * tables/collections/etc. in your schema.                                  *
  *                                                                          *
  * See http://sailsjs.org/#/documentation/concepts/ORM/model-settings.html  *
  *                                                                          *
  * In a production environment (NODE_ENV==="production") Sails always uses  *
  * migrate:"safe" to protect inadvertent deletion of your data.             *
  * However development has a few other options for convenience:             *
  *                                                                          *
  * safe - never auto-migrate my database(s). I will do it myself (by hand)  *
  * alter - auto-migrate, but attempt to keep existing data (experimental)   *
  * drop - wipe/drop ALL my data and rebuild models every time I lift Sails  *
  *                                                                          *
  ***************************************************************************/
  migrate: 'alter',

};

使用上述配置,sails.js 无法在 aws rds 实例中连接或创建表。谁能帮我解决这个问题。提前致谢。

【问题讨论】:

  • 显示错误信息。
  • 嘿 zabware,它没有给出任何错误消息。感谢您的回复。
  • 出错了。生产环境中的 Sails.Js 强制水线使用 'migrate:safe' 而不是 'alter' 或 'drop'。所以,任何表的创建都被禁止了。因此,我用 'migrate:alter' 覆盖了开发配置,并创建了表。

标签: mysql sails.js waterline aws-rds


【解决方案1】:

错了。生产环境中的 Sails.Js 强制水线使用 'migrate:safe' 而不是 'alter' 或 'drop'。所以,任何表的创建都被禁止了。因此,我用“migrate:alter”覆盖了开发配置并运行了sails lift。答对了!已创建所有表。

Sails 能够连接到 rds,但它自己的配置不允许它创建表。

【讨论】:

    猜你喜欢
    • 2021-06-24
    • 1970-01-01
    • 2018-11-10
    • 2017-04-16
    • 1970-01-01
    • 2020-10-19
    • 2020-03-18
    • 2021-06-10
    • 2021-11-27
    相关资源
    最近更新 更多