File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes client cant connect to mysql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "client cant connect to mysql" Watch "client cant connect to mysql" New topic
Author

client cant connect to mysql

miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
i'm very new to this and i used an app that inserts trivial data into a mysql db - and works fine.
now, i've two pcs connected in a network and i changed the localhost to host name and used the app from the client... and worked too... yesterday.
But today it doesnt
i checked the network, the firewall and the code
here's the error msg:
C:\>java -cp .;mysql-connector-java-3.0.9-stable-bin.jar TesteJDBC 1 2
java.sql.SQLException: Invalid authorization specification, message from server
: "Access denied for user: 'root@192.168.0.153' (Using password: YES)"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1825)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1752)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:833)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1734)
at com.mysql.jdbc.Connection.<init>(Connection.java:562)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
:361)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at TesteJDBC.main(TesteJDBC.java:29)
line 29:
conn = DriverManager.getConnection(url);
String url = "jdbc:mysql://<host IP adress/also tried host name>/Test?user=*****&password=*****";
can someone pls help me?
thanks in advance


java amateur
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Did the IP change on that machine you are connecting from? Usually that error is as simple as the user from the specified host does not have access. So basically when you setup a user in MySQL you can specify the @whatever for access. If you specified access to a specific IP then the same user on a different IP won't have access. Does that make sense?


GenRocket - Experts at Building Test Data
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
thanks for your help:
Did the IP change on that machine you are connecting from?

no!, but i recompiled with the host name of the server machine and doesnt work too
Usually that error is as simple as the user from the specified host does not have access. So basically when you setup a user in MySQL you can specify the @whatever for access. If you specified access to a specific IP then the same user on a different IP won't have access. Does that make sense?

what puzzles me the most is that it worked one day (without IP) and the other day didnt(also without IP)
Yes, that makes sense
here's my code in server machine:

[ March 31, 2004: Message edited by: miguel lisboa ]
[ March 31, 2004: Message edited by: miguel lisboa ]
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
No one can give me any idea to help me sorting this out?
thanks in advance
Wayne L Johnson
Ranch Hand

Joined: Sep 03, 2003
Posts: 399
I may be wrong--it's been a while since I've used MySQL--but I believe that out-of-the-box sets the "root" user to have access only from localhost. The idea is that since it's the super-user, you only want to be able to log on using "root" when you're physically on the same box as the server. The error message
Access denied for user: 'root@192.168.0.153' (Using password: YES)
seems to imply that you are trying to log on as "root" from a networked machine.
You need to make sure that there is an authentication entry for "root" that allows remote access, or use a different user/password when trying to connect.
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
thanks for your reply
yes, i solved it now: i needed a grant for the 'other' machine, like this:
mysql> grant all on *.* to root@123.456.7.890 identified by '*****';
now it works perfectly.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: client cant connect to mysql