question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

insecureAuth support (was: bad handshake)

See original GitHub issue

Output: ‘Query error: Bad handshake’

Server: MySQL server 5.0.95 (Linux)

Code:

var mysql = require('mysql2');

var config = {
  host: '127.0.0.1',
  user: 'user',
  password: 'password',
  database: 'database',
  typeCast: false,
  supportBigNumbers: true,
  bigNumberStrings: true,
  insecureAuth: true
}, c;

function doConnect() {
  c = mysql.createConnection(config);
  c.connect(function(err) {
    console.log('Client connected');
  });
  c.on('error', function(err) {
    if (err.code === 'PROTOCOL_CONNECTION_LOST') {
      console.log('Disconnected -- reconnecting ...');
      doConnect();
    } else
      throw err;
  });
}

function doQuery() {
  var count = 0;

  console.log('starting query ...');

  c.query('select * from foo')
   .on('error', function(err) {
     console.log('Query error: ' + err);
   })
   .on('result', function(row) {
     ++count;
   })
   .once('end', function(info) {
     console.log('Query finished successfully');
     console.log(count + ' rows');
   });
}

doConnect();
doQuery();

Issue Analytics

  • State:open
  • Created 10 years ago
  • Reactions:1
  • Comments:35 (23 by maintainers)

github_iconTop GitHub Comments

2reactions
mscdexcommented, Aug 14, 2013

I should note that the same code works with the ‘mysql’ module.

1reaction
midnightcodrcommented, Jan 3, 2018

@sidorares I am getting an empty authSwitchHandlerParams.pluginName when trying to implement what you suggested. marker has a value of 0xfe, asr is

AuthSwitchRequest { pluginName: '', pluginData: <Buffer > }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Sequelize Bad Handshake error - mysql - Stack Overflow
I have a new azure MySQL server and I am trying to use that with my existing Nodejs app. When I try to...
Read more >
Cannot connect from nodejs - MSDN - Microsoft
Upgrade the user password or use the {insecureAuth: true} option. ... message: 'Bad handshake' } { [Error: ER_HANDSHAKE_ERROR: Bad ...
Read more >
Receive "Bad handshake" error when connect MSQL in Azure ...
When I use Login script in database action scripts, MySQL cannot be connected. My node code is as follows: function login(userName, password ...
Read more >
[MXS-2525] before upgrade to 2.3, all works well ,after ...
Upgrade the user password or use the {insecureAuth: true} option ... mysql_error = Bad handshake, mysql_errno = 1045.
Read more >
Node-red-node-mysql 0.0.19 "ER_HANDSHAKE_ERROR
MySQL "bad handshake" after entering password. mysql ... @dceejay Dave, is there a minimum level of MySQL that node-red-node-mysql supports?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found