mysql - "mysql_clear_password" plugin error when using knex but not when using mysql2 -


i trying connect mysql server using mysql_clear_password plugin. set connection configuration node-mysql2 follows:

const connectionconfig = {   host: rwconfig.host,   user: rwconfig.user,   database: rwconfig.database,   ssl: {     ca: sslcontent   },   password } 

then support mysql_clear_password plugin added following (link of reference used: https://github.com/sidorares/node-mysql2/issues/438#issuecomment-255343793):

connectionconfig.authswitchhandler = (data, cb) => {   console.log('in auth switch handler');   if (data.pluginname === 'mysql_clear_password') {     console.log(data);     console.log(data.plugindata.tostring('utf8'));     console.log('in mysql clear password');     var tmppassword = connectionconfig.password + '\0';     var buffer = buffer.from(tmppassword, 'base64');     cb(null, buffer);   } }; 

this works when attempt connect database.

now try similar using knexjs. use following configuration object:

const knexconfig = {   client: 'mysql2',   connection: connectionconfig,   pool: {     min: 0,     max: 20   },   acquireconnectiontimeout: 10000 }; 

the connectionconfig passed in value connection same object used connecting node-mysql2. create knex connection:

const rwconnection = knex(knexconfig); 

this reason throws error:

{ error: client not support authentication protocol requested server; consider upgrading mysql client @ packet.aserror (node_modules/mysql2/lib/packets/packet.js:703:13) @ clienthandshake.command.execute (node_modules/mysql2/lib/commands/command.js:28:22) @ connection.handlepacket (node_modules/mysql2/lib/connection.js:515:28) @ packetparser.onpacket (node_modules/mysql2/lib/connection.js:94:16) @ packetparser.executestart (node_modules/mysql2/lib/packet_parser.js:77:14) @ tlssocket.<anonymous> (node_modules/mysql2/lib/connection.js:386:31) @ emitone (events.js:96:13) @ tlssocket.emit (events.js:188:7) @ readableaddchunk (_stream_readable.js:176:18) @ tlssocket.readable.push (_stream_readable.js:134:10) @ tlswrap.onread (net.js:547:20) code: 'er_not_supported_auth_mode', errno: 1251, sqlstate: '#08004' } 

i don't know why giving me error. in knex documentation (http://knexjs.org/) says:

the connection options passed directly appropriate database client create connection, , may either object, or connection string

based on thought pass configuration through , make connection using node-mysql2. appreciated.

i figured out issue , works now. knex not passing on attributes msyql2 client.

here did else might run problem. modified configurations knex passing mysql2 in node_modules/knex/lib/dialect/mysql2 , added authswitchhandler configoptions array.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -