Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js “如何跟踪错误”;getaddrinfo ENOTFOUND localhost 3306“;_Node.js - Fatal编程技术网

Node.js “如何跟踪错误”;getaddrinfo ENOTFOUND localhost 3306“;

Node.js “如何跟踪错误”;getaddrinfo ENOTFOUND localhost 3306“;,node.js,Node.js,你拼错了 const express = require('express'); const mysql = require('mysql'); const session = require('express-session'); const path = require('path'); const bodyParser = require('body-parser'); const db = mysql.createConnection({ host: "localhol

你拼错了

const express = require('express');
const mysql = require('mysql');
const session = require('express-session');
const path = require('path');
const bodyParser = require('body-parser');

const db = mysql.createConnection({
    host:     "localholst",
    user:     "root",
    password: "password",
    database: "nairobi"
});

db.connect((err) =>{
    if (err) throw err;
    console.log('database connected');
})

const app = express();

app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.use(express.static('public'));

app.get('/', (req, res) =>{
    res.sendFile(path.join(__dirname + '/index.html'));
});
app.post('/auth', (req, res) =>{
    const username = req.body.username; 
})

app.listen(3000, () =>{
    console.log('Server started on port 3000');
});
localholst
更改为
localhost

你把它拼错了

const express = require('express');
const mysql = require('mysql');
const session = require('express-session');
const path = require('path');
const bodyParser = require('body-parser');

const db = mysql.createConnection({
    host:     "localholst",
    user:     "root",
    password: "password",
    database: "nairobi"
});

db.connect((err) =>{
    if (err) throw err;
    console.log('database connected');
})

const app = express();

app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.use(express.static('public'));

app.get('/', (req, res) =>{
    res.sendFile(path.join(__dirname + '/index.html'));
});
app.post('/auth', (req, res) =>{
    const username = req.body.username; 
})

app.listen(3000, () =>{
    console.log('Server started on port 3000');
});

localholst
更改为
localhost

欢迎来到堆栈溢出。请阅读。欢迎来到堆栈溢出。请阅读。非常感谢,它有作用,这花了我8个多小时来找出问题所在。呵呵,谢谢,它有作用,这花了我8个多小时来找出问题所在。呵呵