0

I'm getting error : error:Error: Handshake inactivity timeout

12
  • Can you post the NodeJS code in context? Commented Apr 28, 2016 at 6:20
  • see this post: stackoverflow.com/questions/20210522/… Commented Apr 28, 2016 at 6:23
  • change host : "127.0.0.1" to host : "localhost" Commented Apr 28, 2016 at 6:25
  • @Subburaj I had tried that..but I want to connect without setTimeout i.e.I dont want to wake it up by setting timeout Commented Apr 28, 2016 at 6:30
  • @Abhik Chakraborty ..It dosn't works..Im receiving the same error. Commented Apr 28, 2016 at 6:31

3 Answers 3

1

I connected mysql to node by like this.

Install mysql

npm install mysql

var mysql = require('mysql');

let connection = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    port: '8888',  /* port on which phpmyadmin run */
    password: 'root',
    database: 'dbname',
    socketPath: '/Applications/MAMP/tmp/mysql/mysql.sock' //for mac and linux
});

connection.connect(function(err) {
    if (err) {
      return console.error('error: ' + err.message);
    }

    console.log('Connected to the MySQL server.');
  });
Sign up to request clarification or add additional context in comments.

Comments

0

You can use node-mysql, It very easy to use. I have used once, Here is the example :-

var mysql      = require('mysql');
var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'me',
  password : 'secret',
  database : 'my_db'
});

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();

2 Comments

I had installed node-mysql module.
Im using that only.Thanks for your reply.
0

Use Connection Pool:

var mysql = require('mysql');
var pool  = mysql.createPool({
  host     : 'example.org',
  user     : 'bob',
  password : 'secret'
});

pool.getConnection(function(err, connection) {
  // Use the connection
  connection.query( 'SELECT something FROM sometable', function(err, rows) {
    // And done with the connection.
    connection.release();

    // Don't use the connection here, it has been returned to the pool.
  });
});

3 Comments

But I dont know why Im getting this Error: Handshake inactivity timeout
This is related to node.js. refer this post stackoverflow.com/questions/33101869/…
I'm getting the same error after upgrading to node version 4.2.1 :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.