我已经在我的窗口10上安装了WAMP。我想将节点js服务器与WAMP的MySQL连接。但是我遇到了一些问题。 它在这里引发了错误..
"host" : "localhost",
"user": "root",
"password": "",
"database" : "database"⬅⬅⬅⬅(here)
如果我删除了这个,那么它在控制台上显示连接。
错误:
F:\ Sublime Text 3 \ dailyAttendance \ index.js:15数据库:“public_notice_db”^^^^^^^^ SyntaxError:在Object.runInThisContext上的createScript(vm.js:56:10)处的意外标识符( vm.js:97:10)在Module.load的Module._compile(module.js:542:28)处于Object.Module._extensions..js(module.js:579:10)处(module.js:487: 32)在运行时在Module.runMain(module.js:604:10)的Function.Module._load(module.js:438:3)的tryModuleLoad(module.js:446:12)处(bootstrap_node.js:389: 7)启动时(bootstrap_node.js:149:9)
var express = require('express');
var mysql = require('mysql');
var app = express(); var port = 3001;
app.use(express.static(__dirname+'/'));
app.listen(port);
console.log('Server is running at port '+port);
var con = mysql.createConnection({ host : "127.0.0.1", user : "root", password : "" database : "public_notice_db" });
con.connect(function(err){
if(err)
console.log("There is something wrong...");
else
console.log("Connected..!");
});