简体   繁体   中英

Connect to SQL server via ssh tunnel (ngrok)

I'm making an electron JS app which connects to sql server 2000 using msnodesqlv8. Everything is working fine using localhost but i want to connect to it using a tunnel. I'm trying to use ngrok. This is my connection string:

"Driver={SQL Server};Server={ngrok_tunnel_url};Database={DBname};Uid={sa};Pwd={root};Trusted_Connection={No};"

It works when i pass localhost to server in connection string but when i pass it with a port(1433) it doesn't work. Maybe i'm doing something wrong. can anyone please guide a little bit. Thanks

did ya make any further progress on your question?

Taking a look at the connection string you posted:

"Driver={SQL Server};Server={ngrok_tunnel_url};Database={DBname};Uid={sa};Pwd={root};Trusted_Connection={No};"

&looking at the library source example:

https://github.com/TimelordUK/node-sqlserver-v8/wiki#sequelize-compatibility

const Sequelize = require('sequelize')

let sequelize = new Sequelize({
  dialect: 'mssql',
  dialectModulePath: 'msnodesqlv8/lib/sequelize',
  dialectOptions: {
    'user': '',
    'password': '',
    'database': 'scratch',
    'connectionString': 'Driver={SQL Server Native Client 11.0};Server= np:\\\\.\\pipe\\LOCALDB#2DD5ECA9\\tsql\\query;Database=scratch;Trusted_Connection=yes;',
    'options': {
      'driver': 'SQL Server Native Client 11.0',
      'trustedConnection': true,
      'instanceName': ''
    }
  },
  pool: {
    min: 0,
    max: 5,
    idle: 10000
  }
})

I would try testing an update in your connection string:

Trusted_Connection=no to Trusted_Connection=yes

then see what happens : - )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM