BinaryMan
BinaryMan

Reputation: 289

How to fix Error while reading greeting packet?

I am trying to connect to server in NetBeans. I write the code as below:

<?php
echo "wlecome";
echo "<br>";

$conn=mysqli_connect("mydomain.com:2082", "phpmyadmin_user", "password","database_name");
                     
echo $conn;
?>

Running of this code return this erreurs:

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

Upvotes: 12

Views: 62688

Answers (3)

Use brew services restart [email protected] if you are using mysql 5.7 version.

Upvotes: 0

Zhazgul
Zhazgul

Reputation: 71

Try using only localhost without the port, it worked for me.

Upvotes: 5

TravisO
TravisO

Reputation: 9550

MySQL can be configured to not accept external connections, for security reasons. By saying the full domain name, you are using the public IP and therefore you are an external connection. If MySQL is running on the same box as your webserver, just access it via this domain name:

localhost:2082

Upvotes: 8

Related Questions