【问题标题】:php myqli_connect failed .The server requested authentication method unknown to the client [caching_sha2_password]php myqli_connect 失败。服务器请求客户端未知的身份验证方法 [caching_sha2_password]
【发布时间】:2018-10-09 17:15:12
【问题描述】:

我正在运行 php 7.3。在运行以下代码时:

$conn = mysqli_connect($servername, $username, $hashed_password);

if(!$conn){
    die("Connection failed: " . mysqli_connect_error());
}

我得到的输出是:

Warning: mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password] in C:\localhost\mysql.php on line x

Warning: mysqli_connect(): (HY000/2054): The server requested authentication method unknown to the client in C:\localhost\mysql.php on line x
Connection failed: The server requested authentication method unknown to the client.

修复?

【问题讨论】:

标签: php mysql apache


【解决方案1】:

这是因为 PHP 尚不支持 MySQL 8+ 中的 caching_sha2_password 方法。作为一种解决方法,您可以更改数据库中使用的密码加密,或者您可以恢复到 PHP 7.2.8,它暂时支持它,直到它在下一个版本中再次被删除。

关于该主题的讨论以供将来参考: https://github.com/phpmyadmin/phpmyadmin/issues/14220#issuecomment-434125682

http://php.net/manual/en/mysqli.requirements.php

https://github.com/php/php-src/commit/d6e81f0bfd0cb90586dd83d4fd47a4302605261a#commitcomment-30380461

【讨论】:

    猜你喜欢
    • 2020-12-03
    • 2019-04-24
    • 2018-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-18
    • 1970-01-01
    • 2015-05-02
    相关资源
    最近更新 更多