hombrew installs mysql8 and solves the node connection mysql8 error problem

First check the brew status:

brew doctor confirms that brew is working properly

brew update update version

brew install mysql install mysql

 After executing the above three commands, if a git-related error occurs when installing mysql, execute the prompt command cv in the error and then execute brew install mysql again.

After successful installation, you do not need a password by default to enter mysql -uroot to log in to mysql.

Because the user password authentication strategy of mysql8 has changed from mysql_native_password to caching_sha2_password, the mysql module of nodejs reports an error when starting. Mysql does not support the latest authentication strategy of mysql8.

Modify mysq8 authentication policy:

alter user 'root'@'%' identified with mysql_native_password by 'your password';

% means that any IP host can use root to log in. Your password is the password you modified with the following command:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'New password to be changed'; 

After successfully modifying the policy, use the following command to view it:

select user,plugin from user where user='root' ;

 

At this point the password policy has been modified successfully

Set to allow any remote host connection (the default is to only allow the current localhost connection)

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your password' WITH GRANT OPTION;

Then start the node service and connect to mysql and it will be OK:

 mysql8 modify password policy

Guess you like

Origin blog.csdn.net/Suk__/article/details/129600959