FAQ
Hi,


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.

db_helper.js:
------------------

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
(/Users/Reqall/Downloads/Nodejs-Socketio-Mysql-Demo-master/node_modules/mysql/lib/protocol/sequences/Sequence.js:15:21)
at new Handshake
(/Users/Reqall/Downloads/Nodejs-Socketio-Mysql-Demo-master/node_modules/mysql/lib/protocol/sequences/Handshake.js:9:12)
at Protocol.handshake
(/Users/Reqall/Downloads/Nodejs-Socketio-Mysql-Demo-master/node_modules/mysql/lib/protocol/Protocol.js:36:50)
at Connection.connect
(/Users/Reqall/Downloads/Nodejs-Socketio-Mysql-Demo-master/node_modules/mysql/lib/Connection.js:38:18)
at Connection._implyConnect
(/Users/Reqall/Downloads/Nodejs-Socketio-Mysql-Demo-master/node_modules/mysql/lib/Connection.js:142:10)
at Connection.query
(/Users/Reqall/Downloads/Nodejs-Socketio-Mysql-Demo-master/node_modules/mysql/lib/Connection.js:63:8)
at Object.<anonymous>
(/Users/Reqall/Downloads/Nodejs-Socketio-Mysql-Demo-master/db_helper.js:16:8)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)


Thanks,
Mani.

--
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
nodejs+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupnodejs @
categoriesnodejs
postedNov 14, '12 at 3:44p
activeNov 14, '12 at 3:44p
posts1
users1
websitenodejs.org
irc#node.js

1 user in discussion

Mani s: 1 post

People

Translate

site design / logo © 2022 Grokbase