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个多小时来找出问题所在。呵呵