【问题标题】:how to connect to MySQL databases using php in zend server如何在zend服务器中使用php连接到MySQL数据库
【发布时间】:2019-05-22 23:14:48
【问题描述】:

我正在尝试使用 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";

?>

【问题讨论】:

标签: php mysql zend-server


【解决方案1】:

尝试使用 caching_sha2_password:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-22
    • 2011-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多