Reputation: 432
I'm building an app with Node, Express, and MySql. I'm using MySql version 8.0. I'm using Sequelize and MySQL2 npm package to connect to my database. I have my database connection set up like this, as explained in the Sequelize docs:
config.js
const Sequelize = require("sequelize");
module.exports = new Sequelize("call_on_me", "root", "my password", {
host: "localhost",
dialect: "mysql",
operatorAliases: false,
pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 10000
}
})
And I test the connection in my server file like this:
server.js
const db = require("./config/config");
db.authenticate()
.then(() => console.log("Database connected!"))
.catch(err => console.log("Error: " + err));
When I start up my server, I get an error message that reads:
Error: SequelizeConnectionError: Client does not support authentication protocol requested by server; consider upgrading MySQL client
From what I understand, 8.0 is as high as it goes at the moment, so I can't find anything about upgrading from that. This leads me to believe there's some kind of error in my config connection. Am I missing something? Or am I just failing to understand something very basic that I should know about?
If there's another piece of code you'd need to look at, just let me know.
Thank you in advance for you help.
Upvotes: 0
Views: 201
Reputation: 49375
You have to change the authentication mode, so that it works like in the prior Version of mysql
add this to your my.cnf:
[mysqld]
default_authentication_plugin=mysql_native_password
Do this before adding any users.
Upvotes: 1