我正在运行PHP7.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.
修复?
1条答案
按热度按时间elcex8rz1#
这是因为php还不支持mysql 8+中的caching\u sha2\u password方法。作为一种解决方法,您可以更改数据库中使用的密码加密,也可以恢复到php7.2.8,在下一个版本中再次删除之前,php7.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