{
Error: connect ECONNREFUSED 127.0.0.1:3306
at Object.exports._errnoException (util.js:1020:11)
at exports._exceptionWithHostPort (util.js:1043:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)
--------------------
at Protocol._enqueue (/home/ubuntu/workspace/proj/node_modules/mysql/lib/protocol/Protocol.js:145:48)
at Protocol.handshake (/home/ubuntu/workspace/proj/node_modules/mysql/lib/protocol/Protocol.js:52:23)
at Connection.connect (/home/ubuntu/workspace/proj/node_modules/mysql/lib/Connection.js:130:18)
at Object.<anonymous> (/home/ubuntu/workspace/proj/app.js:12:4)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Timeout.Module.runMain [as _onTimeout] (module.js:604:10)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 3306,
fatal: true }
答案 0 :(得分:0)
好像您的数据库没有在端口3306上运行。
尝试查找端口号并添加端口属性,以便您的代码如下:
var db = mysql.createConnection({
host: "127.0.0.1",
user: "root",
password: "",
database: "udit1",
port: YOUR_PORT_NUMBER_HERE
});