title: ERROR!:SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)
body: <p>I have read many other questions regarding this error, but it doesn't solve mine, that's the reason i made this question despite the obvious thought that many have been asking this before me. </p>
  
  <p>This is my connect.php</p>
  
  <pre><code>&lt;?php
  
  $user = 'root';
  $pass = '';
  
  
  try{
      $dbh = new PDO('mysql:host=localhost;dbname=Login', $user, $pass);
      foreach($dbh-&gt;query('SELECT * from FOO') as $row){
          print_r($row);
      }
  
      $dbh = null;
  } catch (PDOException $e){
      print "ERROR!:" . $e-&gt;getMessage() . "&lt;br/&gt;";
      die();
  
  }
  </code></pre>
  
  <p>But I am having trouble, I am certain that the $user and $pass is correct, but I still keep getting this message, I am new to PDO - can this have anything to do with it?</p>
  
  <p>When I load this on my localhost I get the error message: </p>
  
  <blockquote>
    <p>ERROR!:SQLSTATE[HY000] [1045] Access denied for user
    'root'@'localhost' (using password: NO)</p>
  </blockquote>
  
  <p>To me it seems like this error message is telling me either that the <code>$pass = 'NO'</code> which it doesn't or that the $pass is wrong? I tried to change the <code>$pass = 'NO';</code> and got the following error:</p>
  
  <blockquote>
    <p>ERROR!:SQLSTATE[HY000] [1045] Access denied for user
    'root'@'localhost' (using password: YES)</p>
  </blockquote>
  
  <p>Then - playing stupid here I change <code>$pass = 'YES'</code>;
  got me this error: </p>
  
  <blockquote>
    <p>ERROR!:SQLSTATE[HY000] [1045] Access denied for user
    'root'@'localhost' (using password: YES)</p>
  </blockquote>