Reputation: 59
I am running php 7.3. On running the following code:
$conn = mysqli_connect($servername, $username, $hashed_password);
if(!$conn){
die("Connection failed: " . mysqli_connect_error());
}
I am getting output as:
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.
fix?
Upvotes: 0
Views: 2663
Reputation: 11
This is because support for the caching_sha2_password method in MySQL 8+ is not yet supported by PHP. As a workaround, you can change the password encryption used in your database, or you can revert to PHP 7.2.8, which had temporary support for it until it was removed again in the next version.
Discussions for future reference on the subject: https://github.com/phpmyadmin/phpmyadmin/issues/14220#issuecomment-434125682
http://php.net/manual/en/mysqli.requirements.php
Upvotes: 1