如何在zend server中使用php连接mysql数据库

ejk8hzay  于 2021-06-15  发布在  Mysql
关注(0)|答案(1)|浏览(284)

我试图连接到我的mysql版本8.0.11数据库在zend服务器版本7.2.10使用php,但我无法连接它

Warning: mysqli::__construct(): Unexpected server respose while doing caching_sha2 auth: 109 in C:\Program Files (x86)\Zend\Apache24\htdocs\connectdatabase.php on line 7

Warning: mysqli::__construct(): MySQL server has gone away in C:\Program Files (x86)\Zend\Apache24\htdocs\connectdatabase.php on line 7

Warning: mysqli::__construct(): (HY000/2006): MySQL server has gone away in C:\Program Files (x86)\Zend\Apache24\htdocs\connectdatabase.php on line 7
Connection failed :MySQL server has gone away

当我尝试运行代码时,收到以下警告。
我找了又试 ALTER USER 'username'@'hostname' IDENTIFIED WITH mysql_native_password BY "userpassword" 但对我不起作用

<?php

$servername = "localhost";
$username = "root";
$password = "hello";

$conn = new mysqli($servername,$username,$password);

if(mysqli_connect_error())
{
    die("Connection failed :" . mysqli_connect_error());
}

echo "CONNECTED SUCCESSFULLY";

?>
8yparm6h

8yparm6h1#

尝试缓存\u sha2 \u密码:

ALTER USER 'username'@'hostname'IDENTIFIED WITH caching_sha2_password BY 'userpassword';

相关问题