This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes access denied for user '   '@ipaddress in MYSQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "access denied for user Watch "access denied for user New topic
Author

access denied for user ' '@ipaddress in MYSQL

dee sri
Greenhorn

Joined: Mar 10, 2006
Posts: 5
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

Joined: Mar 06, 2001
Posts: 13459

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

Joined: Mar 10, 2006
Posts: 5
thanks david, it worked!!
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

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

Joined: Sep 18, 2011
Posts: 1
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.*.* ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: access denied for user ' '@ipaddress in MYSQL
 
Similar Threads
struts 2+jboss4.0.4+eclipse
Mysql/JDBC Access Denied Error
mysql query
Exception while connecting to database
client cant connect to mysql