我正在尝试使用php连接到zend服务器版本7.2.10中的MySQL版本8.0.11数据库,但无法连接
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";
?>
答案 0 :(得分:0)
尝试使用caching_sha2_password:
ALTER USER 'username'@'hostname'IDENTIFIED WITH caching_sha2_password BY 'userpassword';