0

I want to connect to a MySQL database from PHP but I can't because "authentication method unknown", I found many solution but all of them about creating a new user with the old password type, but according to the PHP documentation, it should support the new password type. So is it possible to use the new MySQL password type with PHP 7.2.7?

Versions

PHP: 7.2.7
MySQL Server: 8.0.12

PHP Code

// Create connection
$conn = new mysqli($servername, $username, $password);
$conn->set_charset("utf8");
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
echo "Connected successfully";

Result

Connection failed: The server requested authentication method unknown to the client

Noel Nemeth
  • 646
  • 11
  • 21
  • Possible duplicate of [php mysqli\_connect: authentication method unknown to the client \[caching\_sha2\_password\]](https://stackoverflow.com/questions/50026939/php-mysqli-connect-authentication-method-unknown-to-the-client-caching-sha2-pa) – Michael Hampton Nov 09 '18 at 17:09
  • @MichaelHampton I also found this, but as I mentioned PHP 7.2.7 should support the caching_sha2_password, and I think there is a better solution than using the old password type. This is why I posted this question. – Noel Nemeth Nov 09 '18 at 17:41
  • can you [SHOW CREATE USER user](https://dev.mysql.com/doc/refman/8.0/en/show-create-user.html) and show the `php_info` for mysqli. – danblack Nov 11 '18 at 22:07

0 Answers0