Answer the question
In order to leave comments, you need to log in
Why does the application go into error when trying to connect to mysql under node.js?
when you try to execute this code, the application crashes with an error
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 () {
});
Answer the question
In order to leave comments, you need to log in
Most likely the first option will help:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question