我正在运行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.
修复?
答案 0 :(得分:0)
这是因为PHP尚不支持MySQL 8+中的caching_sha2_password方法。解决方法是,您可以更改数据库中使用的密码加密,也可以还原到PHP 7.2.8,该版本对此具有临时支持,直到在下一版本中再次将其删除为止。
有关该主题的讨论,以供将来参考: https://github.com/phpmyadmin/phpmyadmin/issues/14220#issuecomment-434125682