php - 如何在读取问候包和 MySQL 消失时修复错误?
问题描述
我正在尝试将 mysqli 连接到系统。我编写以下代码:
连接文件
<?php
$mysqli = new mysqli('localhost', 'root', 'kemgh23','sistreatment') or die
('cannot reach database');
if($mysqli === false){
die("ERROR: Could not connect. " . $mysqli->connect_error);
}
?>
运行此代码返回此错误:
mysqli::real_connect(): MySQL server has gone away
mysqli::real_connect(): Error while reading greeting packet. PID=16840
mysqli::real_connect(): (HY000/2006): MySQL server has gone away
Connection for controluser as defined in your configuration failed.
mysqli::real_connect(): (HY000/2002): No connection could be made because the
target machine actively refused it.
phpMyAdmin tried to connect to the MySQL server, and the server rejected the
connection. You should check the host, username and password in your
configuration and make sure that they correspond to the information given by the
administrator of the MySQL server.
解决方案
推荐阅读
- linux - 让 rsync 在复制之前对文件进行快照
- android - 构建 JavaScript 包失败。无法解析“expo-barcode-scanner”
- python - Selenium GDPR NoSuchElementException
- javascript - 如何在 Google Maps API 中制作超过 25 个点的路线?
- flutter - 为什么我不能在 Flutter 的 AppBar 中更改 CircleAvatar 或其他圆形小部件的高度?
- ruby-on-rails - 将 Sequel 与 jsonapi-serializer 一起使用
- python - 如何使 argparse 将所有参数视为位置?
- angular - 如何在角度材料中使用“MAT_AUTOCOMPLETE_DEFAULT_OPTIONS”注入令牌
- c++ - 由于 size_t 类型的引用变量而导致分段错误核心转储
- json - 如何在 Swift 中解析来自 Brawl Stars api 的嵌套 JSON 数据?