title: Access denied accessing MySQL from PHP
body: <p>I'm trying to access mysql database from PHP but why do I get error</p>
  
  <pre><code>Warning: mysqli::mysqli(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in /opt/lampp/htdocs/sql.php on line 3
  </code></pre>
  
  <p>Access denied for user 'root'@'localhost' (using password: YES)</p>
  
  <p>I use the login PHP script, I use the correct password and everything</p>
  
  <pre><code>&lt;?php
  
  
  // login.php
  $hn= 'localhost';
  $db= 'publications';
  $un= 'root';
  $pw= 'password';
  ?&gt;
  </code></pre>
  
  <p>And I get error in My PHP script, when I try to connect to it</p>
  
  <pre><code>&lt;?php // query.php
       require_once 'login.php';
       $conn = new mysqli($hn, $un, $pw, $db); // error here on line 3
       .
       .
       .
  ?&gt; 
  </code></pre>