title: Hibernate to MySql: Access denied for user 'root'@'<ip>' (using password: YES)
body: <p>I am trying to connect Hibernate from my local to a remote MySQL database.</p>
  
  <p>Error message:</p>
  
  <pre><code>WARN : org.hibernate.engine.jdbc.internal.JdbcServicesImpl - HHH000342: Could not
  obtain connection to query metadata : Access denied for user 'root'@'&lt;ip&gt;' (using 
  password: YES)
  ERROR: org.hibernate.tool.hbm2ddl.SchemaUpdate - HHH000319: Could not get database 
  metadata
  </code></pre>
  
  <p>hibernate.cfg.xml</p>
  
  <pre><code>    &lt;property name="connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
      &lt;property name="connection.url"&gt;jdbc:mysql://vm-name-001:3306/dbname&lt;/property&gt;
      &lt;property name="connection.username"&gt;root&lt;/property&gt;
      &lt;property name="connection.password"&gt;password&lt;/property&gt;
  </code></pre>
  
  <p>pom.xml</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
          &lt;version&gt;${hibernate-version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;mysql&lt;/groupId&gt;
          &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
          &lt;version&gt;5.1.29&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>In the remote MySQL DB, I issued <code>show grants for 'root'@'%';</code> and received:</p>
  
  <pre><code>...
  | GRANT SELECT, INSERT, UPDATE, DELETE, LOCK TABLES, EXECUTE ON `dbname`.* TO
   'root'@'%'
  | GRANT ALL PRIVILEGES ON `dbname`.* TO 'root'@'%'
  ...
  </code></pre>
  
  <p>If I log into a different VM than the remote MySQL db, I can issue <code>mysql -u root -h vm-name-001 -p</code> and log into it.</p>
  
  <p>My teamate is also saying that he can connect fine using Hibernate, although he is using a Tomcat server.</p>
  
  <p>Edit- My teammate can also connect using a regular java application, outside of Tomcat.</p>
  
  <p>What did I miss?</p>