【问题标题】:AWS RDS MS SQL Unable to connectAWS RDS MS SQL 无法连接
【发布时间】:2018-11-10 15:11:34
【问题描述】:

我正在尝试连接到我新创建的 ms sql 数据库。但是,当我尝试连接时出现错误。错误:无法连接到数据库:{ SequelizeConnectionError: Failed to connect to ....

const sequelize =new Sequelize({
    dialect: 'mssql',
    dialectModulePath: 'tedious',
    dialectOptions: {
 driver: '**SQL Server Native Client 11.0  - is this correct?**',
      instanceName: '**where do i get this?**'
    },
    host: '**what do i put for this?'is this the end point?**',
    port: '1433',
    username: 'username',
    password: 'password,
    database: '**what do i put for this?**',
    pool: {
        min: 0,
        max: 10,
        idle: 10000
      }
  });

【问题讨论】:

  • 我对sequelize不太了解,但是你可以找到instanceName做一个SELECT @@servername,host是endpoint,database是你要连接的数据库的名字(一个 SQL Server 实例为 X 数量的数据库提供服务,每个数据库都有自己的文件)。如果您使用 SSMS,则数据库是下面列出的(猜猜看)“数据库”。

标签: sql-server node.js amazon-web-services sequelize.js amazon-rds


【解决方案1】:

dbname 是您正在与之交互的数据库的名称(您将其输入到 aws)

还要确保你做了npm install tedious -S

const sequelize =new Sequelize('dbname', 'dbusername', 'dbpassword', {
    host: 'http://endpoint-from-aws.com'
    dialect: 'mssql',
    operatorsAliases: false,
    pool: {
        min: 0,
        max: 10,
        idle: 10000
    }
});

http://docs.sequelizejs.com/manual/installation/getting-started.html

【讨论】:

  • 谢谢。如果我将“dbname”留空,则可以连接。但是,当我添加一个值时,我得到一个错误
  • 应该有一个dbname。否则,您必须在每次调用时指定 dbname
【解决方案2】:
const sequelize = await new Sequelize(database, user, password, { host: 'rds-end-point', dialect: 'mysql' });

【讨论】:

  • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
  • 虽然此代码可能会回答问题,但提供有关它如何和/或为什么解决问题的额外上下文将提高​​答案的长期价值。您可以在帮助中心找到更多关于如何写好答案的信息:stackoverflow.com/help/how-to-answer。祝你好运?
猜你喜欢
  • 2017-04-16
  • 1970-01-01
  • 2017-12-13
  • 2016-04-15
  • 2020-12-20
  • 1970-01-01
  • 2017-10-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多