How to connect remotely to mySQL from eclipse IDE

apps

#1

I am playing around with db based websites. (I know that dh does not support Java). I am trying to access my mySQL db hosted by dh from a java project on my local machine.

I can access a locally hosted mySQL db with

Connection con = DriverManager.getConnection(“jdbc:mysql//localhost:3306/testdb_2”,“username”, “password”);

How can i access my dh hosted mySQL db (assuming the host name is “mysql.example.com” and the db name is “testdb_2”?

Thank you

To clarify: I already allowed my computer’s IP address access to the db. I’m asking for the format of the db source string. I tried (“jdbc:mysql//mysql.example.com:3306/testdb_2”,“username”,“password”); but that didn’t work. This is more of a jdbc question specific to dh. I believe all of the configurations on the dh side are already set up.


#2

Goodies > MySQL Databases

  • Click the username in the second row.

  • Add your computer’s public IP to Allowable Hosts


#3

Unless you’ve specifically set it up in the past, you’ll need to allow access to this MySQL database from your IP address. By default, it’s locked down to DreamHost machines only.

You can set this up in the MySQL Databases section of the panel. Click the name of the MySQL user (which will appear next to the database it’s associated with), and add your current IP address to the “Allowable Hosts” section. Keep in mind that your IP address may not be fixed; you might have to come back and update this bit occasionally.


#4

In case anyone ever has the same issue, I have found the solution.

hostname: mysql.example.com
db name: testdb_2
username:admin
password: password

String url = “jdbc:mysql://mysql.example.com:3306/testdb_2”;

Connection con = DriverManager.getConnection(url, “admin”, “password”);