при попытке выполнения данного кода, приложение падает с ошибкой
var express = require('express');
var mysql = require('mysql');
var connection = mysql.createConnection({
host : '127.0.0.1',
database : 'db',
user : 'root',
password : 'password'
});
var app = express();
app.get('/', function (req, res) {
connection.connect();
connection.query('SELECT * FROM users WHERE id = 1', function(err, rows) {
if (err) throw err;
});
});
var server = app.listen(8001, function () {
});
if (err) throw err;
^
Error: connect ECONNREFUSED
at exports._errnoException (util.js:746:11)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:983:19)
--------------------
at Protocol._enqueue (/Users/aleksandrfadeev/node_modules/mysql/lib/protocol/Protocol.js:135:48)
at Protocol.handshake (/Users/aleksandrfadeev/node_modules/mysql/lib/protocol/Protocol.js:52:41)
at Connection.connect (/Users/aleksandrfadeev/node_modules/mysql/lib/Connection.js:109:18)
at /Users/aleksandrfadeev/NetBeansProjects/NodeJS/public_html/server.js:37:16
at Layer.handle [as handle_request] (/Users/aleksandrfadeev/node_modules/express/lib/router/layer.js:82:5)
at next (/Users/aleksandrfadeev/node_modules/express/lib/router/route.js:110:13)
at Route.dispatch (/Users/aleksandrfadeev/node_modules/express/lib/router/route.js:91:3)
at Layer.handle [as handle_request] (/Users/aleksandrfadeev/node_modules/express/lib/router/layer.js:82:5)
at /Users/aleksandrfadeev/node_modules/express/lib/router/index.js:267:22
at param (/Users/aleksandrfadeev/node_modules/express/lib/router/index.js:340:14)
из под php с теми же параметрами к mysql подключается нормально