title: PHP Warning: mysqli_connect(): (HY000/2002): Connection refused
body: <p>I am using PHP 5.5 and MAMP (downloaded from <a href="http://www.mamp.info/en/downloads/" rel="noreferrer">here</a>):</p>
  
  <p>I have a basic script like this:</p>
  
  <pre><code>&lt;?php
  $servername = "127.0.0.1";
  $username = "root";
  $password = "root";
  
  // Create connection
  $conn = mysqli_connect($servername, $username, $password);
  
  // Check connection
  if (!$conn) {
      die("Connection failed: " . mysqli_connect_error());
  }
  echo "Connected successfully";
  ?&gt;
  </code></pre>
  
  <p>and when I run this script I get this error:</p>
  
  <pre><code>PHP Warning:  mysqli_connect(): (HY000/2002): Connection refused in /Applications/MAMP/htdocs/test/test.php on line 7
  </code></pre>
  
  <p>Is there some configuration issue that I need to set up within MAMP or PHP? </p>