Home >Database >Mysql Tutorial >How do I fix the 'ER_NOT_SUPPORTED_AUTH_MODE' error when connecting Node.js to MySQL?

How do I fix the 'ER_NOT_SUPPORTED_AUTH_MODE' error when connecting Node.js to MySQL?

Susan Sarandon
Susan SarandonOriginal
2024-11-21 01:33:15232browse

How do I fix the

Fixing "ER_NOT_SUPPORTED_AUTH_MODE" for MySQL-Node.js Integration

The error "ER_NOT_SUPPORTED_AUTH_MODE" arises while attempting to connect a Node.js server to a MySQL database. This error signifies that the client lacks support for the authentication protocol requested by the server.

Resolving the Issue

To rectify this issue, for MySQL versions 8.0 and above, execute the following query:

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

Substitute "root" with the intended username and "password" with the desired password.

Subsequently, run the "FLUSH PRIVILEGES" command to activate the changes:

FLUSH PRIVILEGES;

Executing these commands successfully resolves the authentication mode incompatibility.

The above is the detailed content of How do I fix the 'ER_NOT_SUPPORTED_AUTH_MODE' error when connecting Node.js to MySQL?. 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