Web Hosting Talk







View Full Version : Remote Database Connections


geobop
07-04-2004, 09:28 AM
I've been pulling my hair out trying to learn PHP and MySQL, then getting everything published online and, more important, making it WORK online. I have had some successful exerperiments, but today I hit a brickwall while trying to import some tables with phpMyAdmin and realized it's time to find a new solution.

In fact, I have two solutions in mind: SSH tunneling and remote database connections.

I've been administering my MySQL databases as much as possible with Navicat, a program that's much easier to use than phpMyAdmin. I just discovered that you can use Navicat online, using a process called SHH tunneling - http://www.navicat.com/ssh_tunnel.php

I'd like to get some feedback from someone who has experience with SSH tunneling - especially if they've also used it with Navicat. Is this fairly easy to learn, or am I just jumping into another can of worms?

At the same time, I want to learn how to make a remote database connection, since one of my websites is much harder to work with than the other. Let's call them www.goodsite.org and www.badsite.org. I want both sites to connect with the database on www.goodsite.org.

I understand I have to go into www.goodsite.org's C-Panel and grant permission for a foreign host to access it. So I open up my C-Panel > MySQL and scroll to the bottom, where it says Access Hosts > Localhost.

I have to type in a value where it says Host (% wildcard is allowed). I understand I have to type in the other website's IP number, so I typed in something similar to 67.33.165.202. But I'm supposed to register TWO IP's if the website's IP address is different than the IP it's hosted on. So how do I type in two IP addreesses, something like this?:

"67.33.165.202, 72.33.126.177"

Another thing I noticed is that the IP address I type in doesn't register. When I typed in the URL - "www.badsite.org" - then clicked the "back" link, "www.badsite.org" was displayed under Access Hosts. But it never displays the IP address, so I can't tell if it's really registered or not.

If and when I solve that problem, I have to put a query that targets a remote database on www.badsite.org. I assume I would use the same password, username and database name that I use on www.goodsite.org, except that I have mark it as a remote connection. Do either of the following queries look correct, or do I have to add "http://" or make some other change?

@mysql_connect ("www.goodsite.org" , "USERNAME" , "PASSWORD");
@mysql_select_db ("DATABASE");

$dbExternal = @mysql_connect ("www.goodsite.org" , "USERNAME" , "PASSWORD");
@mysql_select_db ("DATABASE", $dbExternal);

Finally, I read that many hosts don't allow remote database connections because it's a big security issue. Is that true? If so, what are some safeguards I can use to protect myself from hackers, Microsoft, etc.?

Thanks!

EBH-UK
07-04-2004, 05:15 PM
Hi,

Before I attempt to help, can you tell me a little about your setup. I am not sure why you want to use sites on different IP addresses.

My ideal setup would be to have a host who runs both of your sites, both on the same IP, unless of course one uses SSL, Is this the case?

What was your difficulty with phpMyAdmin, I strongly suggest you master this. If you have root access then you can give yourself the permissions from there.

Remote access of the database daemon does increase the security risks. Again, I am not sure why you would want to do this.

My advice in an ideal world would be to learn MySQL using SSH only to start with, then move onto a graphical tool.

Confirm are you hosting on windows or unix, I am assuming unix?

geobop
07-04-2004, 05:43 PM
Originally posted by EBH-UK
Hi,

Before I attempt to help, can you tell me a little about your setup. I am not sure why you want to use sites on different IP addresses.

My ideal setup would be to have a host who runs both of your sites, both on the same IP, unless of course one uses SSL, Is this the case?

What was your difficulty with phpMyAdmin, I strongly suggest you master this. If you have root access then you can give yourself the permissions from there.

Remote access of the database daemon does increase the security risks. Again, I am not sure why you would want to do this.

My advice in an ideal world would be to learn MySQL using SSH only to start with, then move onto a graphical tool.

Confirm are you hosting on windows or unix, I am assuming unix?

Thanks for the feedback. From the top, my local platform is Apache on Windows XP, but all my websites are remotely hosted on Apache/Linux. I have three different hosts, largely for experimenting and security. I hope to launch a freelance web design/webhosting business soon, and I want to see how the pros do it. Also, I'm very politically active and want to disperse my sites so that if a hacker sneaks through one webhost's defenses, I'll still have some untouched sites.

I'm working on about a dozen websites, and it would make life a lot easier if I could link all of them to two or three central databases. Otherwise, I'll have to publish and update nearly identical copies of the same database to a dozen sites.

I was especially anxious to learn how to make a remote connection earlier today because phpMyAdmin was giving me all sorts of trouble. However, I finally solved that problem and got my tables online.

But since you've confirmed that remote databases are a security risk, maybe I should forget that idea. Or perhaps I'll try it as an experiment with one of my smaller, less important sites and see how long it survives. :)

Thanks again for the tips.

EBH-UK
07-04-2004, 05:59 PM
Your welcome!