I am very new to web development as well as Node.js.

I was trying to execute sample web application using Node.js, which uses
mysql as database to store data.
#npm install mysql ( also socket.io)
# Installed mysql on my laptop, followed steps in readme.txt, setup
username & password for root user, and i was able to run my node program
and accessed mysql database successfully.

Later i wanted to deploy in Heroku, then i found out that i should create
cloud based mysql database to connect for node webapplication to use.
I came to know, they have addons on Xeround mysql database. So i created
account in xeround, created a sample database.
And i was able to access the database through command line.
*#mysql --host=instance31603.db.xeround.com --port=18786 --user=testuser
--protocol=TCP -p*

This worked, i created sample table, added records to it.
Now i changed the hostname, user, password on node program. It was not
connecting to remote database.


var mysql = require('mysql');
var MYSQL_USERNAME = 'testuser';
var MYSQL_PASSWORD = 'joliee';
var HOST_NAME = 'instance31603.db.xeround.com';

// init;
var client = mysql.createConnection({
user: 'testuser',
password: 'xxxxxxxxxxx',
hostname: 'instance31603.db.xeround.com',
port: '18786'

// destroy old db
client.query('DROP DATABASE IF EXISTS mynode_db', function(err) {
//if (err) { throw err; }

// create database
client.query('CREATE DATABASE mynode_db', function(err) {
if (err) { throw err; }

console.log('database mynode_db is created.');

client.query('USE tracker');

// create table
var sql = ""+
"create table employees("+
" id int unsigned not null auto_increment,"+
" name varchar(50) not null default 'unknown',"+
" salary dec(10,2) not null default 100000.00,"+
" primary key (id)"+

client.query(sql, function(err) {
if (err) { throw err; }

console.log('table employees is created.');


I always get this error. Donno how to fix it.Somebody please help me.

Error: connect ECONNREFUSED
at errnoException (net.js:769:11)
at Object.afterConnect [as oncomplete] (net.js:760:19)
at Handshake.Sequence
at new Handshake
at Protocol.handshake
at Connection.connect
at Connection._implyConnect
at Connection.query
at Object.<anonymous>
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)


Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
For more options, visit this group at

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupnodejs @
postedNov 14, '12 at 3:44p
activeNov 14, '12 at 3:44p

1 user in discussion

Mani s: 1 post



site design / logo © 2022 Grokbase