I'm really new to node.js and MySQL, and when I try to learn both at once... let's just say I need some help. ;)
I want to use the node-mysql module to dynamically edit a database via node.js. All the basic code is in place.
var http = require('http'),
mysql = require("mysql");
var connection = mysql.createConnection({
user: "root",
password: "",
database: "ballot"
});
http.createServer(function (request, response) {
request.on('end', function () {
connection.query('SELECT * FROM data;', function (error, rows, fields) {
response.writeHead(200, {
"Content-Type": "text/plain",
'Access-Control-Allow-Origin' : '*'
});
response.write(JSON.stringify(rows));
response.end();
});
});
}).listen(8080);
The problem is, I'm listening on port 8080, and localhost is of course port 80. Should I listen on port 80? If so, how do I do so without messing with Wamp? And how can I access the databases I create with PHPmyAdmin?