title: How to fix "Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'user'@'localhost' (using password: YES)" on MacOS
body: <p>When I try and connect to my database on XAMPP it gives me this error:</p>
  
  <blockquote>
    <p>Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'user'@'localhost' (using password: YES)</p>
  </blockquote>
  
  <p>I have created another user and am logged in to xampp with that. I use the Atom editor and am on macOS Mojave. This is my code - </p>
  
  <pre><code>&lt;?php
   $dbhost = "localhost";
   $dbuser = "username";
   $dbpass = "password";
   $db = "dbname";
  
  
  $conn = new mysqli($dbhost, $dbuser, $dbpass,$db) or die("Connect failed: %s\n".mysqli_connect_error());
  echo "Connected Successfully";
  return $conn;
  
  mysqli_connect_error();
  
  ?&gt;
  </code></pre>
  
  <p>I have written username and password for confidentiality. It is replaced by my real username and password in my code. The same applies to the 'user'@localhost in the error message</p>