mysql icon indicating copy to clipboard operation
mysql copied to clipboard

When using with express/docker-compose; Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client

Open DGKSK8LIFE opened this issue 4 years ago • 5 comments

node_1   | 
node_1   | /app/node_modules/mysql/lib/protocol/sequences/Sequence.js:47
node_1   |   var err  = new Error(code + ': ' + packet.message);
node_1   |              ^
node_1   | Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
node_1   |     at Handshake.Sequence._packetToError (/app/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
node_1   |     at Handshake.ErrorPacket (/app/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)
node_1   |     at Protocol._parsePacket (/app/node_modules/mysql/lib/protocol/Protocol.js:291:23)
node_1   |     at Parser._parsePacket (/app/node_modules/mysql/lib/protocol/Parser.js:433:10)
node_1   |     at Parser.write (/app/node_modules/mysql/lib/protocol/Parser.js:43:10)
node_1   |     at Protocol.write (/app/node_modules/mysql/lib/protocol/Protocol.js:38:16)
node_1   |     at Socket.<anonymous> (/app/node_modules/mysql/lib/Connection.js:88:28)
node_1   |     at Socket.<anonymous> (/app/node_modules/mysql/lib/Connection.js:526:10)
node_1   |     at Socket.emit (events.js:314:20)
node_1   |     at Socket.EventEmitter.emit (domain.js:486:12)
node_1   |     --------------------
node_1   |     at Protocol._enqueue (/app/node_modules/mysql/lib/protocol/Protocol.js:144:48)
node_1   |     at Protocol.handshake (/app/node_modules/mysql/lib/protocol/Protocol.js:51:23)
node_1   |     at Connection.connect (/app/node_modules/mysql/lib/Connection.js:116:18)
node_1   |     at Object.<anonymous> (/app/main.ts:12:4)
node_1   |     at Module._compile (internal/modules/cjs/loader.js:1251:30)
node_1   |     at Module.m._compile (/app/node_modules/ts-node/src/index.ts:858:23)
node_1   |     at Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
node_1   |     at Object.require.extensions.<computed> [as .ts] (/app/node_modules/ts-node/src/index.ts:861:12)
node_1   |     at Module.load (internal/modules/cjs/loader.js:1100:32)
node_1   |     at Function.Module._load (internal/modules/cjs/loader.js:962:14)
node_1   | npm ERR! code ELIFECYCLE
node_1   | npm ERR! errno 1
node_1   | npm ERR! [email protected] go: `ts-node main.ts`
node_1   | npm ERR! Exit status 1
node_1   | npm ERR! 
node_1   | npm ERR! Failed at the [email protected] go script.
node_1   | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
node_1   | 
node_1   | npm ERR! A complete log of this run can be found in:
node_1   | npm ERR!     /root/.npm/_logs/2020-08-19T16_57_55_755Z-debug.log

DGKSK8LIFE avatar Aug 19 '20 16:08 DGKSK8LIFE

I have the same issue while connecting to MySql

BalgopalPatro avatar Aug 22 '20 11:08 BalgopalPatro

Probably related to https://github.com/mysqljs/mysql/pull/2233 if you are using mysql 8.x. I'm not sure why that update to support caching-sha2-password has not been merged yet.

wolfymaster avatar Sep 13 '20 17:09 wolfymaster

I had the same issue. Now I'm using mysql2 and it works. Hopefully this will be improved quickly so that I can switch back again.

LetsMelon avatar Oct 29 '20 12:10 LetsMelon

I had the same issue. Now I'm using mysql2 and it works. Hopefully this will be improved quickly so that I can switch back again.

thank you. Simplest fix ever

drwharris avatar Dec 03 '20 04:12 drwharris

npm uninstall mysql
npm i mysql2

~~const mysql = require('mysql');~~ const mysql = require('mysql2');

const connection = mysql.createConnection({
    host: 'server',
    user: 'u',
    password: 'p',
    database: 'schema_name'
});

ghuser avatar Jan 12 '21 19:01 ghuser