0

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?

  • Possible Duplicate of [MySQL remote connection fails with “unknown authentication method”](https://stackoverflow.com/questions/14612551/mysql-remote-connection-fails-with-unknown-authentication-method). Also figure out the concrete mysql client library and server versions; PHP 8 does not exist yet. – mario Oct 09 '18 at 17:18

1 Answers1

1

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

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

SugarD-x
  • 11
  • 1