作者lin25 (鯊魚~!)
看板java
標題[問題] JDBC error: Access denied for user (using password: YES)
時間Thu Apr 23 23:04:25 2009
最近小玩了一下JDBC
在用localhost做連結時還可以存取資料庫
程式碼如下:
try
{
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection(
jdbc:mysql://localhost:3306/gmap
?useUnicode=true&characterEncoding=Big5",
"root","password");
}
catch(ClassNotFoundException e)
{
System.out.println(e.getMessage());
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}
但是將localhost改成我主機的位址 140.129.19.118 時
就會出現如標題的錯誤
才看一些資料說 可能是帳密打錯
但我帳密跟本沒有變動.....
想知道板上有沒有人知道這種錯怎麼產生的
感謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.160.220.45
推 TonyQ:mysql 外連要另外開 , 確定一下是不是這問題. 04/23 23:13
推 akasan:root預設應該只能localhost 另外開個帳號用吧 04/24 00:54
推 ken915007:最好是開一個使用者,root讓你在localhost測試就好 04/24 09:51
→ lin25:以解決 感謝喔 04/27 00:30