1. ** Nodejs 连接云服务器 MySQL 数据库报错:**Host xx.xx.xxx.xxx is not allowed to connect to this MySQL server;
1
2
3
4
5
6
7
8
1. 先登录
mysql -u root -p"123456";
use mysql;
select host from user where user='root';
2. Host = '%',表示所有 IP 都有连接权限,实际应根据生产环境的 IP 进行设置
update user set host = '%' where user ='root';
3. 刷新权限,让修改生效。
flush privileges;
  1. 需要修改加密规则报错:Client does not support authentication protocol requested by server; consider upgrading MySQL client;
1
2
3
4
5
6
7
8
1. 先登录
mysql -u root -p"123456"
2. 修改加密方式
ALTER USER 'root'@'%' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; // password是正在使用的密码
3. 修改密码
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password'; // password新的密码
4. 刷新权限,让修改生效。
FLUSH PRIVILEGES;