问题描述
在windows中安装了docker,并且在docker中安装了mysql8的镜像。当使用sqlyog连接mysql的时候报错如下:
原因分析
MySQL新版默认使用caching_sha2_password作为身份验证插件,而旧版是使用mysql_native_password
所以,当连接MySQL时报错“plugin caching_sha2_password could not be loaded”时,可换回旧版插件。
解决方案
1、远程命令行登录mysql
sh-4.4# mysql -hlocalhost -uroot -proot -P3306
2、操作mysql数据库命令:
mysql> use mysql;
3、查看用户名使用的身份验证插件:
mysql> select Host,User,plugin from mysql.user;
4、修改root用户的身份验证插件(这里需要修改本地和远程两处):
a、修改本地连接:
mysql> alter user root@localhost identified with mysql_native_password by '123456';
#Query OK, 0 rows affected (0.01 sec)
mysql> FLUSH PRIVILEGES;
#Query OK, 0 rows affected (0.01 sec)
b、远程连接:
mysql> alter user root@'%' identified with mysql_native_password by '123456';
#Query OK, 0 rows affected (0.01 sec)
mysql> FLUSH PRIVILEGES;
#Query OK, 0 rows affected (0.01 sec)
5、最后成功
评论区