连接数据库报plugin caching_sha2_password could not be loaded解决方案

问题描述

连接数据库时出现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;

连接数据库报plugin caching_sha2_password could not be loaded解决方案_第1张图片

4.最后再次连接数据库,出现你喜欢看到的页面!

连接数据库报plugin caching_sha2_password could not be loaded解决方案_第2张图片

你可能感兴趣的:(数据库)