原因
mysql8 之前的版本中加密规则是mysql_native_password,而在mysql8之后,加密规则是caching_sha2_password
解决
mysql -uroot -ppassword #登录use mysql; #选择数据库# 远程连接请将'localhost'换成'%'
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; #更改加密方式ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; #更新用户密码FLUSH PRIVILEGES; #刷新权限