置顶

mysql8.x版本报错: the server requested authentication method unknown to the client

作者:勇康博客网 | 分类:MySQL | 浏览:622 | 日期:2022年03月16日

问题复现:

安装mysql8.0.11时,像往常一样设置mysql密码,设置成功后在shell下输入mysql -u root -p,再输入密码能正常进入,也能通过navicat正常连接,但通过phpmyadmin或其他网页方式操作连接,均提示无法连接,具体报错信息如下:

mysqli_real_connect(): The server requested authentication method unknown to the client [sha256_password]


错误原因:

找到官方文档才发现从8.0.11版本起,caching_sha2_password是默认的身份验证插件,而不是以往的mysql_native_password,密码解锁机制不同,导致tcp方式和http方式连接存在差异


解决:

执行如下代码即可,将身份验证调整为以往方式

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';


发表评论

取消
微信二维码
微信二维码
支付宝二维码