Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

client cant connect to mysql

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No one can give me any idea to help me sorting this out?
thanks in advance
 
Wayne L Johnson
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic