Execute the following query in MYSQL Workbench
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Where root as your user localhost as your URL and password as your password
Then run this query to refresh privileges:
flush privileges;
Try connecting using node after you do so.
If that doesn't work, try it without @'localhost' part.
npm install mysql2
A possible workaround is to alter the type of user account to use the old authentication plugin:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'MyNewPass';
Or create a different one that uses that same plugin:
CREATE USER 'foo'@'localhost' IDENTIFIED WITH mysql_native_password BY 'bar';
import mysql from "mysql2";
const mysql = require("mysql2")
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password ...