Sometimes, we want to fix the ER_NOT_SUPPORTED_AUTH_MODE error when connection to MySQL server from a Node.js app with the mysql library.
In this article, we’ll look at how to fix the ER_NOT_SUPPORTED_AUTH_MODE error when connection to MySQL server from a Node.js app with the mysql library.
How to fix the ER_NOT_SUPPORTED_AUTH_MODE error when connection to MySQL server from a Node.js app with the mysql library?
To fix the ER_NOT_SUPPORTED_AUTH_MODE error when connection to MySQL server from a Node.js app with the mysql library, we call createConnection
with the insecureAuth
option set to true
.
For instance, we write
const connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: '********',
database: 'bill_database',
insecureAuth: true
});
to call createConnection
to make the database connection to the MySQL server with an object with the credentials, database name and host, and some options.
In it, we set insecureAuth
to true
to let us connect to the database with any authentication mode.
Conclusion
To fix the ER_NOT_SUPPORTED_AUTH_MODE error when connection to MySQL server from a Node.js app with the mysql library, we call createConnection
with the insecureAuth
option set to true
.