title: Warning: mysqli_connect(): MySQL server has gone away
body: <p>I wrote a simple PHP code to connect to the MySQL server as below</p>
  <pre><code>&lt;?php
  
  $username = &quot;root&quot;;
  $password = &quot;Kepwd&quot;;
  $hostname = &quot;localhost:81&quot;;
  
  //connection to the database
  $dbhandle = mysqli_connect($hostname, $username, $password)
    or die(&quot;Unable to connect to MySQL&quot;);
  echo &quot;Connected to MySQL&lt;br&gt;&quot;;
  </code></pre>
  <p>but this generates the following errors. I found some topics regarding this issue in google and Stack Overflow. but those don't help me.</p>
  <pre><code>( ! ) Warning: mysqli_connect(): MySQL server has gone away in C:\wamp\www\SSDConsultingNew\inc\test.php on line 8
  Call Stack
  #   Time    Memory  Function    Location
  1   0.0014  240936  {main}( )   ..\test.php:0
  2   0.0014  241528  mysqli_connect ( )  ..\test.php:8
  
  ( ! ) Warning: mysqli_connect(): Error while reading greeting packet. PID=10612 in C:\wamp\www\SSDConsultingNew\inc\test.php on line 8
  Call Stack
  #   Time    Memory  Function    Location
  1   0.0014  240936  {main}( )   ..\test.php:0
  2   0.0014  241528  mysqli_connect ( )  ..\test.php:8
  
  ( ! ) Warning: mysqli_connect(): (HY000/2006): MySQL server has gone away in C:\wamp\www\SSDConsultingNew\inc\test.php on line 8
  Call Stack
  #   Time    Memory  Function    Location
  1   0.0014  240936  {main}( )   ..\test.php:0
  2   0.0014  241528  mysqli_connect ( )  ..\test.php:8
  Unable to connect to MySQL
  </code></pre>