Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL 8: ER_NOT_SUPPORTED_AUTH_MODE [duplicate]

Tags:

node.js

mysql

Setup

  • Expressjs (Node) running in at localhost:3000 on a Windows 10 PC.
  • MySQL ran in a Docker container at 192.168.99.100:3306 via docker-machine.

Problem

When trying to connect server to MySQL using:

const connection = mysql.createConnection({
  host: '192.168.99.100',
  user: 'root',
  password: 'foo123',
  database: 'foo_db'
});

Getting:

Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgr ading MySQL client

Checked many answer here at StackOverflow. Most of them use (example):

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

However I get:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'MyNewPass'; Query OK, 0 rows affected (0.06 sec)

And the server still doesn't want to connect. Using MySQL 5.7 works fine.

Any ideas how to fix this for MySQL 8?


ADDED:

Just to be crystal clear:

  • Using official MySQL Docker: https://hub.docker.com/_/mysql/.
  • server.js gist: https://gist.github.com/h3d0/8d021d25892f34976d806485f18479f2
  • Running MySQL Docker gist: https://gist.github.com/h3d0/505f41a633f571e12117b32638035412
  • Connection to MySQL Docker gist: https://gist.github.com/h3d0/aea7b48144d08403d69e2da3ccdcdde7

After connecting to MySQL, running:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'foo123';
FLUSH PRIVILEGES;

Restarting Node.js and MySQL container and nothing happens.

like image 255
0leg Avatar asked Oct 02 '18 13:10

0leg


1 Answers

I hope you are not using literally the value 'MyNewPass', but it surely looks like it. That's supposed to be an example placeholder.

In your case you would have to do:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'foo123';
like image 141
ruiquelhas Avatar answered Sep 28 '22 09:09

ruiquelhas