[SOLVED] errno: 1251, sqlMessage: 'Client does not support authentication protocol requested by server; consider upgrading MySQL client

Issue

I’m creating the simple api project in nodejs.

For that I have installed mySql workbench with version 8.0.11.
I have created config file, dbConnection.js file and in the dbconnection.js file I have written the following code :

var mysql = require('mysql');
var path = require('path');
var config = require(path.resolve('./', 'config'))

var connection = mysql.createConnection({
    host: config.databaseHost,
    user: config.databaseUser,
    password: config.databasePassword,
    database: config.databaseDatabaseName,
    multipleStatements: true
});

connection.connect(function (err) {
    if (err) {
        console.log('Error connecting to Database',err);
        return;
    }
    console.log('Connection established');
});
module.exports = connection;

And I’m facing following error :

code: ‘ER_NOT_SUPPORTED_AUTH_MODE’,
errno: 1251,
sqlMessage: ‘Client does not support authentication protocol requested by server; consider upgrading MySQL client’,
sqlState: ‘08004’,
fatal: true

Note : I kept my congif as simple as it can be, user = root , password = root, host = localhost.

Solution

Open terminal and login:

mysql -u root -p

(then type your password)

After that:

USE mysql;

UPDATE user SET authentication_string=password(''), plugin='mysql_native_password' WHERE user='root';

And the last important thing is to reset mysql service:

sudo service mysql restart

Answered By – Mohammad Raheem

Answer Checked By – Timothy Miller (BugsFixing Admin)

Leave a Reply

Your email address will not be published.