homebrewmysql-5.7mysql-8.0

"Client does not support authentication protocol requested by server; consider upgrading MySQL client" even after downgrading to mysql@5.7


I was originally on mysql 8.0 which gave me the error

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

when trying to run my server. I saw on multiple sources that downgrading to mysql@5.7 would solve the problem because 5.7 uses native password authentication, but the same error is still present after downgrading to the earlier version. Are there any other known reasons as to why the error still persists?

Here is my config file:

config.js

// import dependencies
const util = require("util");
const mysql = require("mysql");

// import environment variables
const env = {
    env: process.env.NODE_ENV,
    host: process.env.DB_HOST,
    database: process.env.DB_NAME,
    user: process.env.DB_USER,
    password: process.env.DB_PASSWORD
}

const database = mysql.createConnection({
  host: env.host,
  database: env.database,
  user: env.user,
  password: env.password
});

database.connect(err => {
  if (err) {
        console.log("Connection " + err);
  } else {
        console.log(`Connection Success: You are now connected to the ${env.env} database`);
  }
});

// promisify all database queries
database.query = util.promisify(database.query);

// export database
module.exports = database;

Solution

  • MySQL 8.0 introduced a default SHA256 encryption that many clients do not understand. You have many options, the easiest being using the older MySQL native password (see https://mysqlserverteam.com/upgrading-to-mysql-8-0-default-authentication-plugin-considerations/) authentication. Change the account to use the older authentication and your client connector will be happy.