installing mysql ?

83 views
Skip to first unread message

pitambar patra

unread,
Jan 23, 2014, 6:15:49 AM1/23/14
to nod...@googlegroups.com
i am new to node.js ,so trying to read/write to database, but
i am getting the error while compiling my sql1.js file

sql1.js -->
var mysql      = require('mysql');
var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'me',
  password : 'secret'
});

connection.connect();

connection.query('SELECT 1 + 1 AS solution', function(err, rows, fields) {
  if (err) throw err;

  console.log('The solution is: ', rows[0].solution);
});

connection.end();
below is the log

pitambar@pitambar-TravelMate-4740:~/node-example/hands-on-node.js$ npm ls installed
better-...@0.1.3    active installed  
bignum...@1.0.1       active installed  
core-u...@1.0.1       active installed  
c...@0.2.1                active installed  
debu...@0.0.2           active installed  
formi...@1.0.13        active installed  
inhe...@2.0.1           active installed  
my...@2.0.1              active installed  
readabl...@1.1.10   active installed  
requi...@0.0.3        active installed  
under...@1.5.2         active installed  
ut...@0.10.2              active installed
npm ok
pitambar@pitambar-TravelMate-4740:~/node-example/hands-on-node.js$ node sql1.js

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
TypeError: Object prototype may only be an Object or null
    at Function.create (native)

    at Object.inherits (util.js:425:27)
    at Object.<anonymous> (/home/pitambar/.node_libraries/.npm/readable-stream/1.1.10/package/lib/_stream_readable.js:55:6)
    at Module._compile (module.js:402:26)
    at Object..js (module.js:408:10)
    at Module.load (module.js:334:31)
    at Function._load (module.js:293:12)
    at require (module.js:346:19)
    at Object.<anonymous> (/home/pitambar/.node_libraries/.npm/readable-stream/1.1.10/package/readable.js:1:90)
    at Module._compile (module.js:402:26)
pitambar@pitambar-TravelMate-4740:~/node-example/hands-on-node.js$ ^C
pitambar@pitambar-TravelMate-4740:~/node-example/hands-on-node.js$

what to do in such case,i have googled it but no use,
thank you

Fedor Indutny

unread,
Jan 23, 2014, 6:23:38 AM1/23/14
to nod...@googlegroups.com
Hi!

What node.js version are you using?

Cheers,
Fedor.
> --
> --
> 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 nod...@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nodejs+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

pitambar patra

unread,
Jan 23, 2014, 7:28:31 AM1/23/14
to nod...@googlegroups.com
am using latest ver node-v0.10.24


You received this message because you are subscribed to a topic in the Google Groups "nodejs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nodejs/herOSLSh5Oo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nodejs+un...@googlegroups.com.

Scott González

unread,
Jan 23, 2014, 8:45:54 AM1/23/14
to nod...@googlegroups.com
Check for connection errors:

connection.connect(function(err) {
  console.log(err.code); // 'ECONNREFUSED'
  console.log(err.fatal); // true
});


--

pitambar patra

unread,
Jan 23, 2014, 8:52:05 AM1/23/14
to nod...@googlegroups.com
get error while connection, what is the reason for it, how to check that mysql is installed or not, how to make it wrok :)

pitambar@pitambar-TravelMate-4740:~/node-example/hands-on-node.js$ node sql1.js
ECONNREFUSED
true



You received this message because you are subscribed to a topic in the Google Groups "nodejs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nodejs/herOSLSh5Oo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nodejs+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages