navicat 连接不上虚拟机上的mysql容器 client does not support authentication pro

一、问题产生

在centOS 通过docker pull mysql下载mysql镜像并成功启动mysql容器。

当通过windows主机navicat连接虚拟的mysql时报如下错误。Client does not support authentication protocol requested by server; consider upgrading MySQL client

navicat 连接不上虚拟机上的mysql容器 client does not support authentication pro

二、原因查找

通过查看网上别人遇到的相关问题,发现是由于navicat版本的问题,出现连接失败的原因mysql8 之前的版本中加密规则是mysql_native_password,而在mysql8之后,加密规则是caching_sha2_password。并提供了两种解决方案

1.升级navicat,由于navicat是收费的,个人感觉升级会比较麻烦点。

2.把用户密码登录的加密规则还原成mysql_native_password这种加密方式,本人选择第二种解决方案

三、问题解决

按照步骤

1.通过mysql -uroot -p进入mysql的命令行模式

navicat 连接不上虚拟机上的mysql容器 client does not support authentication pro

2.输入命令修改相关机密方法

ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;这里的password是你正在使用的密码

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';#更新一下用户的密码这里的password为你修改的新密码。

FLUSH PRIVILEGES; #刷新权限,使自己的修改生效。

这时还是连接不上,然后通过telnet3306数据库对应的接口,出现了8.0.11;S"3<VN,.Y\k4Ycaching_sha2_password这个信息,是修改没有生效还是其他原因?重启容器之后还是不行。

然后use mysql;

navicat 连接不上虚拟机上的mysql容器 client does not support authentication pro

查询表中的相关信息 select user,host,plugin from user where user='root';

navicat 连接不上虚拟机上的mysql容器 client does not support authentication pro

这时发现了问题,原理刚刚修改的是localhost,对于非本机的连接密码校验规则还是没有变。

 alter user 'root'@'%' identified by 'password' password expire never;

 alter user 'root'@'%' identified with mysql_native_password by 'why';//why是自己新修改的密码。

 flush privileges;再次刷新一下权限配置。

为了确定下,重新查一下,select user,host,plugin from user where user='root';

navicat 连接不上虚拟机上的mysql容器 client does not support authentication pro

修改好了,再用宿主的window电脑访问数据库。

navicat 连接不上虚拟机上的mysql容器 client does not support authentication pro

这时已经连接成功,可以开始下步工作了。