简体   繁体   English

MYSQL 和 PHPMYADMIN 无法通过 php 连接

[英]MYSQL and PHPMYADMIN cant connect via php

Ive set up phpmyadmin and mySql on my windows server but when i try to connect via php i get this error :我已经在 Windows 服务器上设置了 phpmyadmin 和 mySql,但是当我尝试通过 php 连接时,出现此错误:

Warning: mysqli::mysqli(): MySQL server has gone away in C:\xampp\htdocs\newservertest\dbscripts\sqlconnection.php on line 5

Warning: mysqli::mysqli(): Error while reading greeting packet. PID=15852 in C:\xampp\htdocs\newservertest\dbscripts\sqlconnection.php on line 5

Warning: mysqli::mysqli(): (HY000/2006): MySQL server has gone away in C:\xampp\htdocs\newservertest\dbscripts\sqlconnection.php on line 5

Catchable fatal error: Object of class mysqli could not be converted to string in C:\xampp\htdocs\newservertest\dbscripts\sqlconnection.php on line 14

I know by default mySql only allows local connections but following tutorials online they are all saying to uncomment a line in a "my.ini" file.我知道默认情况下,mySql 只允许本地连接,但是在在线教程之后,他们都说要取消注释“my.ini”文件中的一行。 All i have in my sql folder is a my-default.ini with the following :我的 sql 文件夹中只有一个 my-default.ini,其中包含以下内容:

在此处输入图片说明

How can i open this up to connections from an external php script?如何将其打开以连接来自外部 php 脚本的连接?

尝试将其添加到您的 php.ini 中:

mysqli.reconnect = 1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM