I am trying to write a program that can access my database from a remote computer and change it. How can I figure out the url of my database? according to my source it should be something like this

jdbc:mysql://host_name:port/dbname

Thanks for your help.

Recommended Answers

All 9 Replies

This may seem a bit obvious, but ask your web host.
Most have a page in your control panel that tells you the exact answer.

I have emailed my web host, and they have not replied yet. If anyone has any idea about where to look in the cpanel then that would be great to know. I have tried finding it in phpMyAdmin, but I couldn't find it.


thanks for any help.

If your web host is any good chances are that you won't be able to access your database from the outside.
In shared servers mysql is usually ocnfigured to respond only to requests from the local machine, for example from the webserver which runs phpMyAdmin.
Try to access your database with the mysql command line client:

mysql -u<user> -p<password> -h<host> <database-name>

If this works, enter those paremeters in your java connect string.

I cant seem to find the mySQL command line client. I tried to run this in the SQL script are, but it didn't work.

The mysql command line client is in the mysql server package which you can download from mysql.com. Install mysql on your local machine - even if you don't need the server, because the client makes use of some of the libraries -, and then you'll find it in the mysql/bin directory.

If your web host is any good chances are that you won't be able to access your database from the outside.
In shared servers mysql is usually ocnfigured to respond only to requests from the local machine, for example from the webserver which runs phpMyAdmin.
Try to access your database with the mysql command line client:

mysql -u<user> -p<password> -h<host> <database-name>

If this works, enter those paremeters in your java connect string.

I've got several hosts I use, and all let me configure remote access from my home PC. In most control panels, there is an option to allow remote access, usually requiring you to enter the isp's local router name (not your home router, the one you connect to from that). I can then use HeidiSQL (instead of phpmyadmin) from my laptop.

cPanel>Databases>Remote Access

also, to get the connection data,
cPanel > Databases> MySQL Databases allows me to add new databases and define username and password, and to see existing databases, usernames and passwords.

Some hosts only give you one database and usually give the connection strings to use in a help page - this may either be accessible from within your control panel (and can specifically display your connection strings), or from the host's own website (where they tend to give connection strings in a more general format and you have to edit them to include your details).

I just got a reply, and they gave me the IP address. So you're saying I use that IP in my program to connect to and log in using a username and password created for the specific database?

What would the URL look like?

use the IP address as the url, plus username, password, port no. and database name.

All of this you can get from your website control panel - have you actually looked at that yet? It's where I always start when I need database details for a site.

I have looked at it. I have already made my databases, set up emails, and subdomains.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.