Forum Moderators: coopster

Message Too Old, No Replies

Accessing a database on another hosting server!

is it possible?

         

dreamcatcher

4:41 pm on Jan 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have two web hosting accounts. The first one has no databases and unlimited webspace, the second one has limited webspace but unlimited databases.

Is there a way I can access the databases on the server that doesn`t have them from the one that does? I read a previous post about ODBC, but I`m not sure what that is exactly.

Its no big deal, but it would make things easier if I could.

Thank you!

justageek

4:54 pm on Jan 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are using mysql it is as simple as pointing the the ip of the db server.

JAG

coopster

5:06 pm on Jan 24, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Yes, you can access it remotely if your host server is setup to allow it. No, it is not ODBC.
Related links:
mysql_connect to remote server [webmasterworld.com]
Securing a mysql_connect call to a remote host [webmasterworld.com]
server tests wrong username & password [webmasterworld.com]


Little bit o' ODBC info for ya:

ODBC (Open Database Connectivity) is an operating system and database independent communication API that allows a client application (productivity tool, other database, web page, custom application, etc.) to communicate via standards-based function calls to a back end database without relying on that vendor's proprietary communication protocols.

Reference:
ODBC and PHP HOWTO:
h**p://www.iodbc.org/index.php?page=languages/php/index

dreamcatcher

6:01 pm on Jan 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks guys, I didn`t realise it was that simple. Excellent.

:)

dreamcatcher

7:41 pm on Jan 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mmm.....I`m back again. :)

I`m using this syntax to connect on the server that has no database to the server that has.


$mysql_database = "databasename";

$db = mysql_connect("209.****.xxx.xxx","username","password") or die(mysql_error());
mysql_select_db($mysql_database,$db) or die(mysql_error());

But I get an ACCESS IS DENIED message. Is there something I`m missing. I tried some of the syntax from those other posts coopster, but got no joy.

Any ideas?

[edited by: jatar_k at 10:51 pm (utc) on Jan. 25, 2004]
[edit reason] obfuscated ip [/edit]

BitBanger

7:54 pm on Jan 24, 2004 (gmt 0)

10+ Year Member



There is one step missing. You must also inform the host with the database on it, that the host that is attempting to connect is authorized. How you do this is dependant upon the host providing the MySQL database.

If you have CPanel on that host, go to the MySQL management page. At the bottom is an Access Hosts input field. Place the IP address of the web host in that field and add it. This should fix the problem.

dreamcatcher

8:03 pm on Jan 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for that info BitBanger. I actually have an ENSIM control panel, so I`ll take a look there and if I can`t find anything I`ll contact my hosting company about it.

Thanks again! :)

dreamcatcher

10:12 pm on Jan 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just as a follow up, I contacted my hosting company and it is possible as long as I have a static IP address. Which I don`t have. Thats ok, its no biggie, just something I was curious about.

Thanks for the help. :)

BitBanger

3:46 am on Jan 25, 2004 (gmt 0)

10+ Year Member




Just as a follow up, I contacted my hosting company and it is possible as long as I have a static IP address. Which I don`t have. Thats ok, its no biggie, just something I was curious about.

You can't use your domain name? Is your web host on a dynamic IP address?

If your web site is on a shared server, it is certainly possible to do what you want. I can even connect to a MySQL server on a dynamic IP by using dyndns.org.

What you do need to is to determine what name the reverse DNS lookup resolves to. It probably isn't your domain name, but the name of the shared server. The way to determine what the name is, is to attempt to connect to the MySQL server and print the error. Use the standard connect code like this:


mysql_connect ($host, $user, $pass)) or die ('I cannot connect to the database because: ' . mysql_error();

The error will say something like 'I cannot ... because: <some domain name> is not authorized'.

Use the <some domain name> as the access host on the MySQL server.

dreamcatcher

8:38 am on Jan 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks BitBanger. I`m not on a shared server, its two completely seperate accounts with two different hosting companies. It would have made things easier for me if it had of worked, but its no problem, I can work around it.

BitBanger

2:27 pm on Jan 25, 2004 (gmt 0)

10+ Year Member



That is what I was describing. Two seperate web servers, one running the html services, the other running MySQL.

In my particular case I have a machine running MySQL connected via a dynamic IP DSL line. I have an account at dyndns.org for that DSL line that provides DNS lookup. I also have a public web server where the PHP code runs. I then access the public web server from yet another computer.

All these linkages work just fine. What you are describing should be even easier as both servers are public servers with static IP addresses.

It can be done.