title: HY000/2003 error using mysqli to connect on localhost or 127.0.0.1
body: <p>I am writing a php page that connects to a database on WAMP.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>$servername = "127.0.0.1";
  $username = "root";
  $password = "";
  
  // connect to database
  $conn = new mysqli($servername, $username, $password); //error line (1)
  $sql = "USE xdbl0zz14_biodiversity"; 
  $conn-&gt;query($sql); //error line (2)
  </code></pre>
  
  <p>The error line (1) gives the following error:</p>
  
  <pre><code>Warning: mysqli::mysqli(): (HY000/2003): Can't connect to MySQL server on '127.0.0.1' (111)
  </code></pre>
  
  <p>The error line (2) gives the following error:</p>
  
  <pre><code>Warning: mysqli::query(): Couldn't fetch mysqli
  </code></pre>
  
  <p>but I assume that is a direct result of the error before.</p>
  
  <p>I have looked at services.msc and the wampmysqld64 service is started.</p>
  
  <p>Thank you in advance.</p>
  
  <p><strong><em>EDIT</em></strong></p>
  
  <p>The mysql logs show:</p>
  
  <pre><code>2016-04-05T12:05:50.193100Z 0 [Warning] InnoDB: Resizing redo log from      2*3072 to 2*320 pages, LSN=2471251
  2016-04-05T12:05:50.380111Z 0 [Warning] InnoDB: Starting to delete and rewrite log files.
  2016-04-05T12:05:51.310164Z 0 [Warning] InnoDB: New log files created, LSN=2471251
  2016-04-12T11:10:57.423304Z 0 [Warning] wampmysqld64: Forcing close of thread 2  user: 'root'
  
  2016-04-12T22:34:23.288955Z 0 [Warning] wampmysqld64: Forcing close of thread 2  user: 'root'
  </code></pre>