title: PHP MySql (1045) Access Denied For User
body: <p>I've tried to search for an existing answer to this problem, but the answers I find have not worked thus far.</p>
  
  <p>I've been attempting to use PHP to connect to a MySql database. My web host uses cPanel on Linux. The code I'm using to do this seems standard enough:</p>
  
  <pre><code>$mysqli = new mysqli("localhost", "cPanelUsername_dbUsername", "dbPassword", "cPanelUsername_dbName");
  </code></pre>
  
  <p>I've been getting the following error: </p>
  
  <pre><code>Failed to connect to MySQL: (1045) Access denied for user 'cPanelUsername_dbUsername'@'localhost' (using password: YES)Access denied for user 'cPanelUsername'@'localhost' (using password: NO) 
  </code></pre>
  
  <ul>
  <li><em>"localhost"</em> is the host server where the MySql server is located (it seems like this works)</li>
  <li><em>"cPanelUsername"</em> is my cpanel username</li>
  <li><em>"dbUsername"</em> is the database user, which I added to the database with all permissions granted</li>
  <li><em>"dbPassword"</em> is the database password for dbUsername</li>
  <li><em>"dbName"</em> is the database name</li>
  </ul>
  
  <p>I ended up adding my cPanel username before the dbName and dbUsername after searching for answers to this issue elsewhere.</p>
  
  <p>It looks like I have everything set up correctly but it's not connecting (with the error above). I don't have any direct control over the server that I wouldn't have to ask my web host about, which may take a few days to get sorted out. Do I have something wrong with my connection code?</p>