Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client

Tags:

node.js

mysql

Problem in mysql used in nodejs

const mysql      = require('mysql');
var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'root',
  password : '123456789',
  database : 'userdata'
});

connection.connect(function(err) {
  if (err) {
    console.error('error connecting: ' + err);
    return;
  }

 console.log('connected as id ' + connection.threadId);
});

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

like image 551
Kumar Avatar asked Oct 15 '18 11:10

Kumar


People also ask

How do I update MySQL workbench?

Step 2: Navigate to Software > MySQL Upgrade or type “MySQL” into the search bar. You may also find it under SQL Services > MySQL/MariaDB Upgrade. Step 3: Select the version of MySQL you want to upgrade to and click Next. Now follow the upgrade steps, and it'll take care of everything for you.

How can I tell what version of MySQL is installed on Windows?

Windows users can employ PowerShell or the command prompt and Linux and MacOS have the Terminal. To check the version your MySQL is running, type and execute mysql -V (note the uppercase V) in the command line. As you can see, the MySQL version for this system is 10.4.


2 Answers

Had the same problem.

Install MySQL Workbench

Execute this query: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456789'; in MySQL Workbench

Head back over to Node.js and try running the file again. It should work, at least it did for me.

like image 101
Margaret Smith Avatar answered Oct 12 '22 03:10

Margaret Smith


In any database software (mysql workbench,datagrip, dbeaver...):

First run this query:

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

Second, if your problem still persists, run this query:

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password'; 

Combining and running these two queries separately worked for me with dockorize mysql.

like image 39
joah Avatar answered Oct 12 '22 02:10

joah