解决宿主机无法连接到虚拟机中docker容器中的mysql问题:1251-client does not support authentication protocol requested······

由于mysql 8.0默认使用caching_sha2_password认证导致宿主机无法连接。解决方案包括进入mysql容器,登录后修改root用户的加密方式为mysql_native_password,从而修复连接问题。
摘要由CSDN通过智能技术生成

原因:mysql 8.0 默认使用 caching_sha2_password 身份验证机制;客户端不支持新的加密方式。

解决方案

—修改root用户的加密方式
1、进入mysql容器中

docker exec -it 1728bfe17bdd bash //1728bfe17bdd为容器id,使用docker ps命令即可查看

在这里插入图片描述

2、登录mysql

mysql -u root -p

在这里插入图片描述
3、查看用户信息并修改加密方式

select host,user,plugin,authentication_string from mysql.user; //查看用户信息

在这里插入图片描述

:host下面的为%表示user中的root用户不限制ip,但是其对应的plugin为caching_sha2_password而不是mysql_native_password,需要修改为mysql_native_password。

ALTER USER 'root'@
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
"Client does not support authentication protocol requested by server; consider upgrading MySQL client" 是一个MySQL数据库的错误信息,意思是客户端的身份验证协议不被服务器所支持。这个错误通常在使用旧版本的MySQL客户端与新版本的MySQL服务器进行连接时出现。解决这个问题的方法是升级你的MySQL客户端。 如果你在使用Docker容器MySQL,请确保你所使用的MySQL镜像是最新版本,或者尝试使用兼容的MySQL客户端。你可以通过以下步骤解决这个问题: 1. 首先,确认你正在使用的MySQL镜像是最新版本,并且支持你所使用的MySQL服务器版本。 2. 如果你正在使用的MySQL镜像不是最新版本,可以尝试更新镜像到最新版本,或者使用兼容的MySQL客户端。 3. 如果你仍然遇到这个问题,可以尝试使用其他MySQL客户端,确保其与你的MySQL服务器版本兼容。 4. 另外,你还可以尝试在连接MySQL服务器时使用更安全的身份验证方式,例如使用SSL/TLS加密连接。 总之,当出现"Client does not support authentication protocol requested by server; consider upgrading MySQL client"错误时,你需要确认你的MySQL客户端与服务器的版本兼容,并尝试升级客户端或使用兼容的客户端来解决这个问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [mysql Client does not support authentication protocol requested by server; consider upgrading MySQL](https://blog.csdn.net/qq_35835624/article/details/81510547)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [【已解决1251 - Client does not support authentication protocol requested by server; consider ...](https://blog.csdn.net/mjh1667002013/article/details/127603034)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [MYSQL出现" Client does not support authentication "的解决方法](https://download.csdn.net/download/weixin_38744435/12837374)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值