You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PHP 8.3连接MySQL 8时遇caching_sha2_password认证未知错误求解决

问题:PHP 8.3.7 无法通过caching_sha2_password连接MySQL 8数据库

已安装并运行PHP 8.3.7(经phpinfo()确认),尝试连接MySQL 8数据库时触发以下致命错误:

PHP Fatal error: Uncaught mysqli_sql_exception: The server requested authentication method unknown to the client [caching_sha2_password]

查阅资料得知PHP 8.3应该原生支持caching_sha2_password认证方式,但目前能找到的临时解决方法只有将MySQL用户强制改为已停用的mysql_native_password——这是过时特性,我更希望让原生的SHA认证功能正常工作,而非依赖旧方案。

未找到任何说明提及PHP需要特殊配置才能支持该认证方式,猜测自己遗漏了某些明显的配置项。

phpinfo()显示关键信息:

8.3.7 Client API library version mysqlnd 8.3.7

完整错误栈信息:

Fatal error:** Uncaught mysqli_sql_exception: The server requested authentication method unknown to the client [caching_sha2_password] in /[...]/testSO01.php:13 Stack trace: #0 /[...]/testSO01.php(13): mysqli_connect() #1 {main} thrown in /[...]/testSO01.php on line 13

内容的提问来源于stack exchange,提问作者Frédéric Vivien

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 23:47:02