Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I'm getting ER_NOT_SUPPORTED_AUTH_MODE. Why? #2046

Closed
rivques opened this issue Jun 9, 2018 · 8 comments
Closed

I'm getting ER_NOT_SUPPORTED_AUTH_MODE. Why? #2046

rivques opened this issue Jun 9, 2018 · 8 comments

Comments

@rivques
Copy link

rivques commented Jun 9, 2018

When I try to make a basic connection, it gives me this error:

Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
    at Handshake.Sequence._packetToError (/Users/riverlewis/Desktop/node/mysql-test/node_modules/mysql/lib/protocol/sequences/Sequence.js:52:14)
    at Handshake.ErrorPacket (/Users/riverlewis/Desktop/node/mysql-test/node_modules/mysql/lib/protocol/sequences/Handshake.js:130:18)
    at Protocol._parsePacket (/Users/riverlewis/Desktop/node/mysql-test/node_modules/mysql/lib/protocol/Protocol.js:279:23)
    at Parser.write (/Users/riverlewis/Desktop/node/mysql-test/node_modules/mysql/lib/protocol/Parser.js:76:12)
    at Protocol.write (/Users/riverlewis/Desktop/node/mysql-test/node_modules/mysql/lib/protocol/Protocol.js:39:16)
    at Socket.<anonymous> (/Users/riverlewis/Desktop/node/mysql-test/node_modules/mysql/lib/Connection.js:103:28)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:279:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at Socket.Readable.push (_stream_readable.js:219:10)
    --------------------
    at Protocol._enqueue (/Users/riverlewis/Desktop/node/mysql-test/node_modules/mysql/lib/protocol/Protocol.js:145:48)
    at Protocol.handshake (/Users/riverlewis/Desktop/node/mysql-test/node_modules/mysql/lib/protocol/Protocol.js:52:23)
    at Connection.connect (/Users/riverlewis/Desktop/node/mysql-test/node_modules/mysql/lib/Connection.js:130:18)
    at Object.<anonymous> (/Users/riverlewis/Desktop/node/mysql-test/app.js:11:5)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)

My code is

// app.js
const mysql = require('mysql');

// First you need to create a connection to the db
const con = mysql.createConnection({
  host: 'localhost',
  user: 'user',
  password: 'secret'
});

con.connect((err) => {
  if(err){
    throw err;
    }
  console.log('Connection established');
});

con.end((err) => {
  // The connection is terminated gracefully
  // Ensures all previously enqueued queries are still
  // before sending a COM_QUIT packet to the MySQL server.
});
@sidorares
Copy link
Member

What is your server version? Mysql 8 switched to different default auth mode which is not yet supported by this library.

Possible duplicate of #2002

@rivques
Copy link
Author

rivques commented Jun 10, 2018

Mysql server is version 8.0.11.

@rivques
Copy link
Author

rivques commented Jun 10, 2018

After looking at a comment on #1962, I can get it to work with what @ruiquelhas has done:

everything should still work if you use the mysql_native_password plugin.

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourRootPassword';
-- or
CREATE USER 'foo'@'%' IDENTIFIED WITH mysql_native_password BY 'bar';

However, it would be good for it to work without plugins.

@sidorares
Copy link
Member

However, it would be good for it to work without plugins.

It's in progress, see #1962

@Garamda
Copy link

Garamda commented Jan 3, 2019

@rivques Thank you so much! You fixed my bug :)

@emanuelgustavo
Copy link

This line resolve my problem too,

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourRootPassword';

@Dilo07
Copy link

Dilo07 commented Jan 13, 2021

This line resolve my problem too,

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourRootPassword';

Hi Emanuel, Did you run this command on MySql Workbench?

Andrea

@ganeshhubale
Copy link

This line resolve my problem too,

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourRootPassword';

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

7 participants