aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Connection refused, i can't log in to my SQL-Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Connection refused, i can Watch "Connection refused, i can New topic
Author

Connection refused, i can't log in to my SQL-Server

Markus Reis
Greenhorn

Joined: Jan 06, 2013
Posts: 12
Hi all together.

I'm currently working on a web-application for university. First of all, the mySQL-Installation didnt work, which i fixed now. But as I try to run my code, i recieve the following exception:






As I found out by checking different ports, this error always occurs, even if there's no server running, so I guess the server is not listening, but why?
Netstat looks like this, so I think the server is running:


Btw, if I'm trying via browser:


Moreover, if I start mySQL from xampp (i run it on 3306 there), EVERY single port I try says "access denied" (and yes I'm sure the password isnt wrong ;D), also the ones where is no server running as well as 3306 itself.

So first of all: How do I get on either the SQL-Workbench started server or the xampp server?
And second: Where is even the difference? Does xampp provide an own sql server or does it start one from the software i installed??

Would be awesome if someone could help, google didnt help me at all yet and I start to retire

best regards
markus
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2627
    
    9

Welcome to the Ranch

You mentioned you are using port 3310, but MySQL default port is 3306.

You mentioned you have XAMP, if XAMP started can you access MYSQL?

One way to check is indeed using netstat. If you don't use netstat you can use telnet <host> <port>

Another approach is use the command line to access MySQL.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
Markus Reis
Greenhorn

Joined: Jan 06, 2013
Posts: 12
Hey there, thanks

I use port 3310 due to this Youtube Tutorial as I also had installation troubles. He then uses 3310 for fixing the problem. But on 3306 XAMPP now is running, and if I go to localhost on the browser xampp site opens, and I can also access to phpMyAdmin and create tables and databases etc, and the password there is the same as i try to use in my code. If I try to access 3306 (so the one from xampp) i get the error:



(if i open localhost:3306 in browser i get "J���
5.5.27�š���tL^sJTIQ�ÿ÷�€����������<wep(q%`4%Wj�mysql_native_password�!��ÿ„#08S01Got packets out of order)

So imo the server is running, isnt it? But why cant I contact it
Markus Reis
Greenhorn

Joined: Jan 06, 2013
Posts: 12
btw. if I test with telnet I get the same gibberish and native password stuff as if I connect via browser
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18991
    
    8

This error message

java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)


confirms that you are connecting to the server, so you can stop testing for that. It is telling you that you have not configured MySQL to accept connections from the 'root' user, or that you have used the wrong password, or something like that.
Markus Reis
Greenhorn

Joined: Jan 06, 2013
Posts: 12
yep thats true. But the password and user are correct, because on shell they work.

So what else could it be? How can I accept connections?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18991
    
    8

You actually have to configure that in MySQL somehow. It's so many years ago that I did it, I forget how, but if I recall correctly, it isn't enough to just set up a password for the user ID. You also have to configure something which tells MySQL it's okay to accept connections from that user ID and from a particular host, or from all hosts (I think).
Markus Reis
Greenhorn

Joined: Jan 06, 2013
Posts: 12
Ok, I dont know exactly what I did wrong before, but I followed the steps by this Tutorial (using my Files) and now it runs the program on localhost. Whatever I did wrong before or whoever else has the same problem, check out that link
 
 
subject: Connection refused, i can't log in to my SQL-Server