开发者

Error in remote mySQL access

I am trying to remotely access mySQL server. This is the code used by me.

 Connection conn = null; 
    try 
    { 
       String url = "jdbc:mysql://172.18.227.237:3306/struts2"; 
       Class.forName ("com.mysql.jdbc.Driver"); 
       conn = DriverManager.getConnection (url,"root","admin"); 
       System.out.println ("Database connection established"); 
    } 

But I get the following error:

 com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Access denied for user 'root'@'172.20.169.174' to database 'struts2'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1026)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:910)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3923)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1273)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2031)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:718)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:298)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.开发者_如何学GogetConnection(Unknown Source)
at com.Connect.main(Connect.java:17)

I have been granted access permission to my IP, But yet I get error.


Have you flushed the privileges after granting access to root at that IP? Privileges won't work until they have been loaded by the MySQL engine, so you have to issue a 'FLUSH PRIVILEGES' command.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜