title: Unable to connect to MYSQL database from java
body: <p>I'm new into MySQL and UNIX, Actually from one UNIX box to another i connected using <code>ssh -i commonprivatekey -p 60041 root@172.16.28.102</code>. Once it connected then I'm executing <code>mysql -uroot -ppassword mysql</code> mysql prompt open i can able execute select command. </p>
  
  <p>Env Details:</p>
  
  <pre><code>IP               : 172.16.28.102
  SSH Port         :  60041
  usernames        :  root
  passwords        :  password
  SSH Privatekey   :  commonprivatekey
  mySQL DB Port    :  60040
  mySQL DB Name    :  mysql
  mySQL DB UserID  :  root
  mySQL DB Password:  password
  </code></pre>
  
  <p>And my Java code is</p>
  
  <pre><code>try {
    Class.forName("com.mysql.jdbc.Driver");
    conn = DriverManager.getConnection("jdbc:mysql://172.16.28.102:60040/mysql", "root", "password");
  }  catch (SQLException e) {
    logger.error("Could not connect to the database", e);
  }
  </code></pre>
  
  <p>Exception trace:</p>
  
  <pre><code>Caused by: java.sql.SQLException: null,  message from server: "Unknown error 1130"
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
      at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1095)
      at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2031)
      at com.mysql.jdbc.ConnectionImpl.&lt;init&gt;(ConnectionImpl.java:718)
      at com.mysql.jdbc.JDBC4Connection.&lt;init&gt;(JDBC4Connection.java:46)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
      at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
      at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
      at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
      at java.sql.DriverManager.getConnection(DriverManager.java:664)
      at java.sql.DriverManager.getConnection(DriverManager.java:247)
      at uk.accenture.fdt.batch.control.ConnectionsHelper.getDatabaseConnection(ConnectionsHelper.java:35)
  </code></pre>