1

I Have installed mysql 8.0 and try to connect it with php 5.6 and getting following error.

Warning: mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password]

Warning: mysqli_connect(): (HY000/2054): The server requested authentication method unknown to the clien

Error: Unable to connect to MySQL. Debugging errno: 2054 Debugging error: The server requested authentication method unknown to the client

Anuj Mishra
  • 11
  • 1
  • 1
  • 5

1 Answers1

0

the mysqli library It may not be support on some servers; Use PDOinstead. Use these codes for connecting to Database with PDO:

    <?php
    $Host = "localhost";
    $dataBase = ""; //Write here the Name of Database
    $userName = ""; //Write here your username
    $Password = ""; //Write here your password
    $setName = array(PDO::MYSQL_ATTR_INIT_COMMAND =>'SET NAMES utf8');

    try{
        $connect = new PDO("mysql:host = $Host;dbname = $dataBase",$userName,$Password,$setName);
        echo 'Success...';
    }catch(PDOException $error) {
        echo 'Error !'. $error->getmessage();
    }
    ?>