Kumar
Kumar

Reputation: 297

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

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

Upvotes: 25

Views: 50162

Answers (6)

talharim
talharim

Reputation: 1

someone can tell me how this command works?

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

Upvotes: 0

sosnus
sosnus

Reputation: 1340

Solution using PhpMyadmin

  1. login on server as root
  2. click "User accounts" enter image description here
  3. Find user which You will use to login by client
  4. Click "Change password" enter image description here
  5. Type Your old password, then change Password Hashing to Native MySQL authentication enter image description here
  6. Click "Go"
  7. Password and auth method was changed. Now try use Your client.

Upvotes: 2

syed ahemed buhary
syed ahemed buhary

Reputation: 11

update node-version to 16.X or greater and change the module from 'mysql/sync-mysql' to 'mysql2' in node api file

Upvotes: 1

joah
joah

Reputation: 81

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.

Upvotes: 8

tamilselvan s
tamilselvan s

Reputation: 1119

Best Solution try this it will resolve:

You installed mysql server using "mysql installer"

1)open -> "mysql intsaller"

2)press reconfig mysql server

3)select left side "authentication method tab"

4)select radio button -->use legacy authentication method

5)now stop and restart the db 

Thanks!

Upvotes: 10

Margaret Smith
Margaret Smith

Reputation: 508

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.

Upvotes: 46

Related Questions