title: Uncaught PDOException: SQLSTATE[HY000] [1045] Access denied for user 'dbuser'@'localhost' (using password: YES)
body: <p>Most answers were that it would be a right issue. But I assume not in this case, because mysql-connection still worked.</p>
  
  <p>I am trying to connect to a mariadb10, which was on a server in my network<br>
  I am trying to connect from my localhost.</p>
  
  <p>If I try in my terminal:</p>
  
  <pre><code>myuser@mylocalComputer ~ $ mysql -h myserver -P 3307 -u mydbuser -pmyconfidentalpassword
  </code></pre>
  
  <p>everything works fine!!</p>
  
  <p>But If I try to connect by php scrypt by pdo I get the error:</p>
  
  <pre><code>&lt;?php
  $dsn = 'mysql: host=myserver:3307;dbname=mydbname';
  $username = 'mydbuser';
  $password = 'myconfidentalpassword';
  $options = array(
      PDO::MYSQL_ATTR_INIT_COMMAND =&gt; 'SET NAMES utf8',
  ); 
  $dbh = new PDO($dsn, $username, $password, $options);
     if(! $dbh ) {
        die('Could not connect: ' . mysql_error());
     }
  
     $sql = 'select * from foo;';
     $retval = mysql_query( $sql, $conn );
  
     if(! $retval ) {
        die('Could not select data: ' . mysql_error());
     }
  
     echo "Synced data successfully\n";
     mysql_close($conn);
  
  ?&gt;
  </code></pre>
  
  <p>The Error was:</p>
  
  <blockquote>
    <p>PHP Fatal error:  Uncaught PDOException: SQLSTATE[HY000] [1045] Access
    denied for user 'mydbuser'@'localhost' (using password: YES) in
    /home/myuser/Projekte/Hibiscus_extend/Hib_Nightly_sync.php:8</p>
  </blockquote>
  
  <p><br></p>
  
  <blockquote>
    <p>Stack trace:</p>
    
    <blockquote>
      <p>/home/myuser/Projekte/Hibiscus_extend/Hib_Nightly_sync.php(8):
      PDO->__construct('mysql: host=myse...', 'mydbuser',
      'myconfidentalpassword', Array)<br> <br> {main}   thrown in
      /home/myuser/Projekte/Hibiscus_extend/Hib_Nightly_sync.php on line 8</p>
    </blockquote>
  </blockquote>
  
  <p>What did I do wrong, and where?</p>