I have a remote mysql database server setup on a machine myuniversity.edu and server is named 'localhost'. On it I have the database named 'MyDatabase'.
I want to connect it through Java.
The connection urls that I have tried are:
jdbc:mysql://myuniversity.edu/localhost
jdbc:mysql://myuniversity.edu/localhost/MyDatabase
jdbc:mysql://myuniversity.edu:3306/MyDatabase
but I get the `Connection refused: connect` exception.
Could someone please tell what the connection url should be in this case?
localhostor127.0.0.1refers to your current computer (there even are jokes about it, like this). The name of the server must bemyuniversity.edu. If it's not available through your network like that, try using it's IP (something like10.0.0.15)myuniversity.eduis a domain name so to access your mysql remotely you either need to know a domain name (e.g.server) of a machine where mysql is running and then use the full domain name (e.g.server.myuniversity.edu) or you need to know an IP address of that machine. You can uselocalhostonly to connect to local (on the same machine) instance of mysql.hostnamecommand, and you can find its IP address by listing the interfaces (network cards) usingifconfig -ajdbc:mysql://theipaddress:3306/MyDatabasebut I get the same error.I checked the bind-address in my.cnf file and it's 127.0.0.1Could you please tell me if it should be the ip address of the host?