我正在尝试连接到NetBeans中的服务器。代码如下:
<?php
echo "wlecome";
echo "<br>";
$conn=mysqli_connect("mydomain.com:2082", "phpmyadmin_user", "password","database_name");
echo $conn;
?>
运行这段代码会返回以下错误:
wlecome
Warning: mysqli_connect(): MySQL server has gone away in C:\xampp\htdocs\myprojet\index.php on line 10
Warning: mysqli_connect(): Error while reading greeting packet. PID=1092 in C:\xampp\htdocs\myprojet\index.php on line 10
Warning: mysqli_connect(): (HY000/2006): MySQL server has gone away in C:\xampp\htdocs\myprojet\index.php on line 10
Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\myprojet\index.php on line 10
3条答案
按热度按时间e4eetjau1#
出于安全原因,MySQL可以配置为不接受外部连接。通过说完整的域名,你正在使用公共IP,因此你是一个外部连接。如果MySQL与您的Web服务器运行在同一个机器上,只需通过此域名访问它:
muk1a3rh2#
尝试只使用
localhost
没有端口,它为我工作。qmb5sa223#
使用brew服务重启email protected(https://stackoverflow.com/cdn-cgi/l/email-protection)如果你使用mysql 5.7版本。