Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

access denied for user ' '@ipaddress in MYSQL

 
dee sri
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting the following error while connecting to mysql server 4.1 from tomcat 5.0.3 .Tomcat is running in linux and mysql is in a different windows machine.
The problem is the linux IP '172.19.63.57' is shown in the error message instead of the windows IP which is specified in the datasource of struts-config.xml of tomcat in linux.A part of the datasource is as follows

<data-source type="org.apache.commons.dbcp.BasicDataSource">
<set-property
property="driverClassName"
value="com.mysql.jdbc.Driver" />
<set-property
property="url"
value="jdbc:mysql://172.19.63.199:3306/test?autoReconnect=true" />
<set-property
property="username"
value="root" />
<set-property
property="password"
value="root" />

In the errors below the user is showing as ' ' instead of root.


Server connection failure during transaction. Due to underlying exception: 'java.sql.SQLException: Access denied for user ''@'172.19.63.57' (using password: NO)'.

** BEGIN NESTED EXCEPTION **

java.sql.SQLException
MESSAGE: Access denied for user ''@'172.19.63.57' (using password: NO)

STACKTRACE:

java.sql.SQLException: Access denied for user ''@'172.19.63.57' (using password: NO)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2847)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:750)
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to set up mysql to allow remote connection for any users. The default syntax is:

grant <permission> on <database> to <user>@<location> identified by <password>

eg
grant all on test.* to root@172.19.63.57 identified by root

Will allow 'root' to connect from that IP using that password and give all permissions on all tables in that database.
 
dee sri
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks david, it worked!!
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fantastic, thanks for getting back to us. I'm still not sure about the ''@IP, but it was worth a shot
 
Saeid Beik-Rassouli
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David O'Meara wrote:You need to set up mysql to allow remote connection for any users. The default syntax is:

grant <permission> on <database> to <user>@<location> identified by <password>

eg
grant all on test.* to root@172.19.63.57 identified by root

Will allow 'root' to connect from that IP using that password and give all permissions on all tables in that database.


Thank you, great help. is there a way to specify a mask 172.19.*.* ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic