2016-02-19 246 views
0

有什麼我失蹤? 我的遠程MySQL數據庫是谷歌雲和我訪問了我目前的外部IP:mySQL遠程數據庫沒有連接

String myDriver = "org.gjt.mm.mysql.Driver"; 
String myURL = "jdbc:mysql://<remote IP address here>:3306/test"; 
System.setProperty("useSSL", "true"); 
System.setProperty("user", "test"); 
System.setProperty("password", "test"); 
System.setProperty("javax.net.ssl.keyStore","lib\\keystore"); 
System.setProperty("javax.net.ssl.keyStorePassword","password here"); 
System.setProperty("javax.net.ssl.trustStore","lib\\truststore"); 
System.setProperty("javax.net.ssl.trustStorePassword","password here"); 
Class.forName(myDriver); 
connection = DriverManager.getConnection(myURL, System.getProperties()); 
System.out.println("Connection successful."); 

它告訴我訪問被拒絕。

這裏是堆棧跟蹤:

Access denied for user 'test'@'my external IP' (using password: YES) 
java.sql.SQLException: Access denied for user 'test'@'my external IP' (using password: NO) 
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957) 
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3878) 
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3814) 
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:871) 
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1694) 
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1215) 
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2255) 
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2286) 
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2085) 
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:795) 
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44) 
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:404) 
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:400) 
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:327) 
at java.sql.DriverManager.getConnection(Unknown Source) 
at java.sql.DriverManager.getConnection(Unknown Source) 
at Test.main(Test.java:16) 
+0

顯示詳細資料/ stacktrace – michaldo

回答

0

檢查,如果你可以使用以下命令遠程登錄的IP地址。 telnet遠程-ip端口。

至於如果u谷歌的telnet端口@ 80的例子:

的telnet 8.8.8.8 80

你會看到這樣的響應:

試圖8.8.8.8 ... 連接到8.8。 8.8。 轉義字符是'^]'。

當你使用telnet remote-ip時,應該會觀察到類似的結果。如果沒有這個端口不是在谷歌雲打開或您的ISP提供商阻止傳出交通@端口3306.

+0

我有mySQL Workbench,我可以連接到我的遠程數據庫,我可以訪問它通過SSL等,爲什麼我需要嘗試遠程登錄?加上我目前正在使用的筆記本電腦有Windows 10 –