When I try to run the below program I am get error as MySQL server has gone away.
<?php
$servername = "localhost";
$username = "root";
$password = "";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
Google says that it is due to
2
Try to debug the problem. This can be caused by any number of things. Commonly there are:
- The MySQL server crashed
- A comms problem between the client and server
- Abusing the client library in a way not intended, perhaps sending commands out of order or sending junk through the socket.
I came to solution as to debug the problem. How to debug to find the correct reason as to why this error is happening?