-1

I use NetBeansIDE PHP Version 5.6.8,want to connect mysql,so I use the code:

<?php
header("Content-type:text/html;charset=UTF-8");
$mysqli = new mysqli("127.0.0.1", "root", "", "elective_manage",3306);
if ($mysqli->connect_error) {
    echo "不能连接到数据库<br/>";
}
print "成功连接至数据库!";
?> ```

**But it failed connect mysql database,the error message is :
Warning: mysqli::mysqli(): The server requested authentication method unknown to the client [caching_sha2_password] in D:\xampp\htdocs\xk\teacher\course_teacher.php on line 7
Warning: mysqli::mysqli(): (HY000/2054): The server requested authentication method unknown to the client in D:\xampp\htdocs\xk\teacher\course_teacher.php on line 7
不能连接到数据库
成功连接至数据库!**
Our teacher uses MySQL that comes with xampp. He can connect normally, but mine can't.I also used sqlyog to test whether my database can be connected correctly. It turns out that it can.
I also changed the encoding method of Mysql to match PHP, but it didn't work.
**I have try to change mysql's caching_sha2_password in to native,but it doesn't work.**
Mysql version is 8.0.23,if somebody know how to resolve it ,**help me please~!**
Kris
  • 1
  • (1) Either upgrade your PHP to say PHP 7/8 ; or (2) change you mysql so that it uses mysql_native_password – Ken Lee May 11 '22 at 05:38

0 Answers0