这个问题是由于我的MySQL的的的更新至8版本以上了,在安装的时候我并没有指定用户登入密码加密方式,所以默认被设置为caching_sha2_password
解决方法:
mysql> show variables like 'default_authentication_plugin';
Variable_name | Value |
---|
default_authentication_plugin | caching_sha2_password |
查看本地mysql用户的信息
mysql> select host,user,plugin from mysql.user;
host | user | plugin |
---|
localhost | mysql.infoschema | caching_sha2_password |
localhost | mysql.session | caching_sha2_password |
localhost | mysql.sys | caching_sha2_password |
localhost | root | caching_sha2_password |
注意 caching_sha2_password, 只修改root的密码加密方式就可以了
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
mysql> select host,user,plugin from mysql.user;
host | user | plugin |
---|
localhost | mysql.infoschema | caching_sha2_password |
localhost | mysql.session | caching_sha2_password |
localhost | mysql.sys | caching_sha2_password |
localhost | root | mysql_native_password |