尝试通过knex连接到Mssql服务器 [英] Trying to connect to Mssql server via knex

查看:159
本文介绍了尝试通过knex连接到Mssql服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用knex连接到远程数据库,但出现此错误: 不推荐使用乏味.options.encrypt的默认值将从false更改为true.如果要保留当前行为,请显式传递false.node_modules \ mssql \ lib \ tedious.js:212:23 未处理的拒绝ConnectionError:无法连接到151.80.119.227,14831:1433-getaddrinfo ENOTFOUND 151.80.119.227,14831"

I'm trying to connect to a remote database with knex but I get this error: "tedious deprecated The default value for options.encrypt will change from false to true. Please pass false explicitly if you want to retain current behaviour. at node_modules\mssql\lib\tedious.js:212:23 Unhandled rejection ConnectionError: Failed to connect to 151.80.119.227,14831:1433 - getaddrinfo ENOTFOUND 151.80.119.227,14831"

我可以通过Microsoft sql服务器管理工​​作室使用相同的主机,用户,密码进行连接,所以我迷路了.

I can connect via Microsoft sql server management studio with same host, user, password so I'm lost.

这就是我创建knex var的方法:

This is how I create my knex var:

 var knex = require('knex')({
  client: 'mssql',
  connection: {
    server : '151.80.119.227,14831',
    user : '****',
    password : '****',
    database : '****'
  }
});

我可以使用以下命令通过python连接到

I can connect to it via python with:

 con = pyodbc.connect("DRIVER={SQL Server};server=151.80.119.227,14831;database=*****;uid=****;pwd=****")

那么为什么它不通过node.js连接....

So why won't it connect through node.js ....

推荐答案

实际上应该在MSSQL options变量中指定端口:

Port should actually be specified in the MSSQL options variable:

 var knex = require('knex')({
  client: 'mssql',
  connection: {
    server : '151.80.119.227',
    user : '****',
    password : '****',
    database : '****',
    options: {
      port: 14831
    }
  }
});

这是从阅读 https上的代码获得的://github.com/tgriesser/knex/blob/v0.16.2/src/dialects/mssql/index.js

这篇关于尝试通过knex连接到Mssql服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆