title: Connection failed: Connection refused mysql (LAMP)
body: <p>When I try to connect to mysql it refuses my script. I have mysql installed on ubuntu 16.10 (LAMP).</p>
  
  <p>When I run this:</p>
  
  <pre><code>&lt;?php
  $servername = "ip";
  $username = "user";
  $password = "pw";
  
  // Create connection
  $conn = new mysqli($servername, $username, $password);
  
  // Check connection
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  } 
  echo "Connected successfully";
  ?&gt;
  </code></pre>
  
  <p>It shows: </p>
  
  <blockquote>
    <p>Connection failed: Connection refused mysql (LAMP)</p>
  </blockquote>
  
  <p>I tried to change the bind-address to 0.0.0.0, then it showed:</p>
  
  <blockquote>
    <p>Connection failed: Host 'webserver1' is not allowed to connect to this MySQL server</p>
  </blockquote>
  
  <p>I tried to comment (#) the bind-address. That didn't work either.</p>
  
  <p>I am running the scripts on a client with another ip-range/subnet then the mysql-server. When I run phpmyadmin on the client I have no problem.</p>