title: JDBC / MYSQL: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)
body: <p>With this code</p>
  
  <pre><code>String url = "jdbc:mysql://localhost/mysql";
  Connection con = DriverManager.getConnection(url, "root", "");
  </code></pre>
  
  <p>I get the following exception. </p>
  
  <pre><code>java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:943)
      at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4113)
      at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1308)
      at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2336)
      at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2369)
      at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2153)
      at com.mysql.jdbc.ConnectionImpl.&lt;init&gt;(ConnectionImpl.java:792)
      at com.mysql.jdbc.JDBC4Connection.&lt;init&gt;(JDBC4Connection.java:47)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
      at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)
      at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at MyTest1.main(MyTest1.java:29)
  </code></pre>
  
  <p>I logged into the database using the command tool with root and no password. I was able to telnet to the database and I get this message</p>
  
  <pre><code>N
   5.5.17-log
             7{*Zj%u☻Ç§|tR}=Vz'L,6imysql_native_password"
  </code></pre>