mysql icon indicating copy to clipboard operation
mysql copied to clipboard

ER_NOT_SUPPORTED_AUTH_MODE

Open alexsaelao opened this issue 4 years ago • 4 comments

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

I have this problem, pleases recomend how to fix that Thou you very much

My code:

const {
    createPool 
} = require('mysql');

const pool = createPool ({
    host: "127.0.0.1",
    user: "root",
    password: "",
    database: "api_db",
    connectionLimit: 10
})

pool.query(`SELECT * FROM po_view`, (err, result, field) => {
    if(err) {
        return console.log(err);
    } 
    return console.log(result)
})

module.exports = pool

alexsaelao avatar Jun 30 '21 10:06 alexsaelao

It looks like this node module doesn't support "caching_sha2_password" authentication. It's been introduced maybe in MySQL 8.0. In the meantime you can downgrade your mysql user:

$ sudo mysql -u root
mysql> ALTER USER the_user IDENTIFIED WITH mysql_native_password BY 'the_password';

Please keep in mind this doesn't fix the issue, it just downgrades your user password so it can be used with mysqljs' mysql node module.

matonga avatar Jul 30 '21 14:07 matonga

It looks like PR https://github.com/mysqljs/mysql/pull/2233 would solve your issue.

matonga avatar Jul 30 '21 14:07 matonga

It looks like I prefix my sentences with "It looks like"... :joy_cat:

matonga avatar Jul 30 '21 14:07 matonga

It looks like this node module doesn't support "caching_sha2_password" authentication. It's been introduced maybe in MySQL 8.0. In the meantime you can downgrade your mysql user:

$ sudo mysql -u root
mysql> ALTER USER the_user IDENTIFIED WITH mysql_native_password BY 'the_password';

Please keep in mind this doesn't fix the issue, it just downgrades your user password so it can be used with mysqljs' mysql node module.

It works for me! Thanks!

ginlink avatar Oct 06 '21 10:10 ginlink