title: MySQL: Access denied for user 'userName'@'localhost'
body: <p>I am having an issue with creating and grating permissions to a user using phpMyAdmin. I am having a Java swing application and it need to connect to this database.</p>
  
  <p>How I created the user and granted the permission are below, step by step.</p>
  
  <ol>
  <li>Open phpMyAdmin</li>
  <li>Go to 'Users' tab.</li>
  <li>Click on <code>Add New User</code></li>
  <li>Give the user name, select <code>Any Host</code> as the host (so the % is displayed in its text box), and mention the password. <code>Any host</code> is because remote access required.</li>
  <li>Select <code>Select</code> under <code>Global Privileges</code> - <code>Data</code></li>
  <li>Click on <code>Go</code></li>
  <li>Now I am in the <code>Users</code> tab starting page again. </li>
  <li>Click on <code>Edit Privileges</code> on my newly created user.</li>
  <li>Select the database under <code>Database-specific privileges</code></li>
  <li>Tick everything under <code>Database-specific privileges</code>, <code>Data</code> section.</li>
  <li>Click on <code>Go</code></li>
  </ol>
  
  <p>Now, whenever my Java application connects to this, it gives the below error</p>
  
  <pre><code>java.sql.SQLException: Access denied for user 'userName'@'localhost' (using password: YES)
  </code></pre>
  
  <p>This is how I connect to the database, in my Java application</p>
  
  <pre><code>con = DriverManager.getConnection("jdbc:mysql://"+ip+":3306/databaseName","user","password");
  </code></pre>
  
  <p>Here,for the variable <code>ip</code>, I tried both <code>localhost</code> and <code>127.0.0.1</code> but still no good. What have I done wrong?</p>
  
  <p>I noticed the connection works fine if I select <code>Localhost</code> instead of <code>Any Host</code> in step 4.</p>