【mysql】解决报错:SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

【mysql】解决报错:SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

依然范儿特西
2021-06-26 / 1 评论 / 298 阅读 / 正在检测是否收录...

错误信息提示

SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

原因

由于MySQL 8默认使用了新的密码验证插件:caching_sha2_password,而低版本的PHP版本中所带的mysqlnd无法支持这种验证。故报“请求客户端未知的身份验证方法”。

解决

方案一

可以通过phpinfo()函数了解当前安装的PHP是否支持caching_sha2_password

方案二

更改加密方式


alter user 'root'@'localhost' identified with mysql_native_password by '123456';
flush privileges;
2

评论 (1)

取消
  1. 头像
    隔壁老王
    Windows 10 · Google Chrome

    卧槽。今天就遇到了。感谢博主

    回复