MySQL NodeJS

NodeJS MySQL 8.x Connection Error

October 9, 2019

Just upgrading from Sierra To Catalina and MySQL 5.x to MySQL 8.x. Suddenly the NodeJS project couldn’t connect to MySQL.
MySQL 8.0 made a change on its default auth plugin.

There are some ways to deal with this. Either reset the user password to use the old auth method or totally reset the MySQL default auth plugin.

Change only using old auth method for specific user, run queries below (change the user, password, host as needed)

ALTER USER 'myuser''@'localhost' IDENTIFIED WITH mysql_native_password BY 'mypassword';
FLUSH PRIVILEGES;


Change the default auth plugin in MySQL config file:

[mysqld]

default_authentication_plugin=mysql_native_password