1

我试图MySQL使用JAVA相同的代码连接本地主机中的数据库。现在我尝试在我的系统中使用它来更新远程数据库。这是我的代码:

import java.sql.*;
class mysqlConnect { 

public static void main (String[] args) { 
    try { 
        String url = "jdbc:mysql://dibyaranjan.net76.net/a3932573_product";
        Connection conn = DriverManager.getConnection(url,"a3932573_dibya","*****"); 
        Statement st = conn.createStatement(); 
        st.executeUpdate("INSERT INTO emp_oracle " + "VALUES (1001, 'Dibya', 'AAA')"); 
        conn.close(); 
    } catch (Exception e) { 
        System.err.println(e.getMessage()); 
    } 

}
} 

我收到此错误消息: null, message from server: "Host '49.204.14.98' is not allowed to connect to this MySQL server"

ip是我的公共ip。

4

2 回答 2

1

Error is clear. You cant connect to the remote mysql server from your machine. a3932573_dibya this user is not having permission to connect from this IP.

When you create a user in mysql, we can also specify which all IP's this user will connect from. If you want to allow all IPs you should give host as %

于 2012-12-15T18:42:06.113 回答
0

您的主机在mysql.user表中配置不正确。

打开并在表格PHPMyAdmin中找到您的记录。表,以便主机名而不是或任何其他 IP 反映您的实际 IP(或者如果您希望允许来自每个 IP 的连接。但是请注意,大多数共享主机不允许这种配置。mysql.userALTERlocalhost127.0.0.1%

更多参考:http ://blog.wassupy.com/2011/02/host-is-not-allowed-to-connect-to-this.html

于 2012-12-15T18:49:37.473 回答