node-mysql2: insecureAuth support (was: bad handshake)
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();
About this issue
- Original URL
- State: open
- Created 11 years ago
- Reactions: 1
- Comments: 35 (23 by maintainers)
I should note that the same code works with the ‘mysql’ module.
@sidorares I am getting an empty
authSwitchHandlerParams.pluginName
when trying to implement what you suggested.marker
has a value of0xfe
,asr
isWould definitely give it a try.
this is also relevant - https://github.com/sidorares/node-mysql2/issues/504
one problem could be that plugin name is reported as empty string - can you verify this? ( add console log in auth switch handler )