title: XAMPP Mysql connection error in php from remote system
body: <p>I have windows 7 system and installed xampp in it. </p>
  
  <p>I can access phpmyadmin using <a href="http://ipaddress:8080/phpmyadmin" rel="nofollow">http://ipaddress:8080/phpmyadmin</a> from remote system.</p>
  
  <p>But if i try to access it from php it will give me error :</p>
  
  <blockquote>
    <p><strong>Warning: mysqli::mysqli(): (HY000/2013): Lost connection to MySQL server at 'reading initial communication packet', system error: 20</strong></p>
  </blockquote>
  
  <p><strong>My php code is</strong></p>
  
  <pre><code>define("HOST", "X.X.X.X");
  define("PORT", "port");     // The host you want to connect to.
  define("USER", "user");    // The database username. 
  define("PASSWORD", "password");    // The database password. 
  define("DATABASE", "DBname");    // The database name.
  
  $mysqli =  new mysqli(HOST, USER, PASSWORD, DATABASE, PORT); 
  // or without port $mysqli =  new mysqli(HOST, USER, PASSWORD, DATABASE); 
  
  if ($mysqli-&gt;connect_errno) {
      printf("Connect failed: %s\n", $mysqli-&gt;connect_error);
      exit();
  }
  </code></pre>
  
  <p>I have also tried firewall turning off, and also allow port 3306 to firewall, but no luck. Granted all PRIVILEGES to this user with host any (%).</p>
  
  <p>I have also tried using bind_address = 0.0.0.0, commenting that line, and also bind_address = X.X.X.X (my IP).</p>
  
  <p>Also tried changing socket type from "MySQL" to "TCP/IP". skip-networking line is also commented default.</p>
  
  <p>I have tried to access from command prompt using:</p>
  
  <p>mysql -h X.X.X.X -u root -p</p>
  
  <p>This will give error:</p>
  
  <blockquote>
    <p><strong>Warning: mysqli::mysqli(): (HY000/2003): Can't connect to MySQL server on 'X.X.X.X' (110).</strong></p>
  </blockquote>
  
  <p>Using localhost in same system in connection string it works fine.</p>
  
  <p>Where i am wrong i can't figure out. I have searched and tried all possible solutions.
  Thanks for help.</p>
  
  <p>Note: rather than above, right now my conf file is same as at time of installation. Please don't mark this question as duplicate.</p>
  
  <p>Edit: @Jay Blanchard, As i have referred that solution also, in that case system error : 0, in my case system error : 20. Thanks for help.</p>