dqtu14636 2019-01-25 09:32
浏览 264

mysqli :: __ construct():客户端未知的身份验证方法[caching_sha2_password] x [重复]

I've just installed xampp and I'm running a MySQL db locally on phpMyAdmin. I'm trying to output the contents of a database via a .php doc, but I'm getting two warnings when trying to do so:

Warning: mysqli::__construct(): The server requested authentication method unknown to the client [caching_sha2_password] in C:\xampp\htdocs\footfallTracker\test.php on line 20

Warning: mysqli::__construct(): (HY000/2054): The server requested authentication method unknown to the client in C:\xampp\htdocs\footfallTracker\test.php on line 20 Connection failed: The server requested authentication method unknown to the client

Here's the code I'm using:

     <?php
$servername = "localhost";
$username = "root";
$password = "*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19";
$dbname = "footfall_tracking";

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

$sql = "SELECT ID, Location, Date FROM footstep_count";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo "ID: " . $row["ID"]. " - Location: " . $row["Location"]. " - Date: " . $row["Date"]. "<br>";
    }
} else {
    echo "0 results";
}
$conn->close();
?> 
</div>
  • 写回答

1条回答 默认 最新

  • douci1677 2019-05-22 00:09
    关注

    This code helped me

    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password
    BY 'password';
    

    You can check it here :D The server requested authentication method unknown to the client (PHP) thi

    评论

报告相同问题?

悬赏问题

  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了