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

    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP