I am trying to create a connection between Visual Studio Code and MS SQL Server Management Studio 18. I have found numerous tutorials that have the same code that I pretty much just copied and pasted.
const mysql = require('mysql');
//create connection
const db = mysql.createConnection({
host: 'serverName',
user: 'userName',
password: 'password',
database: 'dbName',
});
//connect to mysql environment
db.connect(err =>{
if(err){
console.log(err);
}else{
console.log("Connected");
}
});
db.end();
I have 3 SQL services all up and running (SQL Server, Server Browser, Server Agent) and I have not been able to get rid of this error
Error: connect ECONNREFUSED 192.168.0.27:3306
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16)
--------------------
at Protocol._enqueue (C:\Users\Administrator\Desktop\SQL Connection\node_modules\mysql\lib\protocol\Protocol.js:144:48)
at Protocol.handshake (C:\Users\Administrator\Desktop\SQL Connection\node_modules\mysql\lib\protocol\Protocol.js:51:23)
at Connection.connect (C:\Users\Administrator\Desktop\SQL Connection\node_modules\mysql\lib\Connection.js:116:18)
at Object.<anonymous> (C:\Users\Administrator\Desktop\SQL Connection\connect.js:19:4)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '192.168.0.27',
port: 3306,
fatal: true
}
I have looked all over the internet for help but haven't found anything that works. So does anyone have any suggestions??