Home >Database >Mysql Tutorial >Why Do I Get 'ER_NOT_SUPPORTED_AUTH_MODE' When Connecting to MySQL 8.0 with Node.JS?

Why Do I Get 'ER_NOT_SUPPORTED_AUTH_MODE' When Connecting to MySQL 8.0 with Node.JS?

Patricia Arquette
Patricia ArquetteOriginal
2024-12-19 15:04:13902browse

Why Do I Get

MySQL 8.0 - Client Authentication Protocol Error

When attempting to connect to a MySQL 8.0 database using Node.JS, you may encounter the error message:

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

This error indicates that the MySQL client is using an outdated authentication protocol that is not compatible with the server.

Solution:

To resolve this issue, you can execute the following queries in MySQL Workbench:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

Replace 'root' with your MySQL username, 'localhost' with the host address, and 'password' with your desired password.

After executing this query, run the following query to refresh privileges:

flush privileges;

Now, attempt to connect to the database using Node.JS again.

If the error persists, try executing the first query without the @'localhost' part:

ALTER USER 'root' IDENTIFIED WITH mysql_native_password BY 'password';

This should resolve the authentication protocol mismatch and allow you to successfully establish a connection to the database.

The above is the detailed content of Why Do I Get 'ER_NOT_SUPPORTED_AUTH_MODE' When Connecting to MySQL 8.0 with Node.JS?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn