Home >Database >Mysql Tutorial >How do I fix the 'ER_NOT_SUPPORTED_AUTH_MODE' error when connecting Node.js to MySQL?
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.
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!