Im making a small Node.js app hosted on Heroku and Im trying to access the free MySQL db service at my school. Ive set up a db there and everything is a-ok. However, I cant seem to connect from my server.
The server code is this:
var express = require('express');
var app = express.createServer(express.logger());
var mysql = require("db-mysql");
new mysql.Database({
"hostname": "mysql.stud.ntnu.no",
"user": "removed",
"password": "removed",
"database": "removed"
}).connect(function(error) {
if (error) {
return console.log("CONNECTION error: " + error);
}
this.query()
.select(["name", "kcal", "carb"])
.from("matvarer")
.execute(function(error, rows, columns){
if (error) {
console.log('ERROR: ' + error);
return;
}
console.log(rows.length +" rows found");
});
});
The error I get in the Heroku log is this :
2012-04-27T18:04:48+00:00 heroku[web.1]: Stopping process with SIGTERM
2012-04-27T18:04:49+00:00 app[web.1]: CONNECTION error: Lost connection to MySQL server at 'reading initial communication packet', system error: 0
Does anyone have any clues what this is? Ive tried so many different variants of getting connected to a db from Heroku now...
Thanks in advance