问题描述
连接数据库时出现plugin caching_sha2_password could not be loaded报错
原因分析:
因为MySQL新版默认使用caching_sha2_password作为身份验证的插件,而旧版本使用的是mysql_native_password。当出现plugin caching_sha2_password could not be loaded报错,我们更换为旧版本
解决方案:
docker exec -it mysql bash
1.使用远程命令行登录mysql
mysql -hlocalhost -uroot -proot -P3306
登录成功后会出现
2.操作数据库命令:
use mysql;
3.修改root用户的身份验证插件
本地连接:
alter user root@localhost identified with mysql_native_password by '123456';
FLUSH PRIVILEGES;
远程连接:
alter user root@'%' identified with mysql_native_password by '123456';
FLUSH PRIVILEGES;
4.最后再次连接数据库,出现你喜欢看到的页面!