FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


How to connect 2 database from 2 host





thedinh
colud anyone here help me !
i have 2hosts i i want to connect dadabase of them together
that means i put my code website on host A and now i want to conncet to database on host B.
the code i use is PHP
is it possible
and could any one help me
Rolling Eyes Rolling Eyes Rolling Eyes
Marcuzzo
yes it is possible, you need to allow host to access the DB.
you need to use the propper host name instead of localhost when creating the connection.
what do you have so far?
mindfox
thedinh wrote:
could anyone here help me !
i have 2hosts i i want to connect database of them together
that means i put my code website on host A and now i want to connect to database on host B.
the code i use is PHP
is it possible
and could any one help me
Rolling Eyes Rolling Eyes Rolling Eyes


Before we're able to give a proper suggestion/solution to your request, you need to give us more details on what you have and what you want to achieve.
And to be more specific:

    Do you own the servers?
    If not, what permissions do you have on them?
    Are those servers distant or within the same network?
    What is your DB server?
    If there's any firewall installed, do you have any control on it?
    Do you have permission / are you able to change the connect permissions of the DB account of your DB?
    Why do you want to split the functionality?


To give you some hints, it's generally not advisable to open access to your DB server from the public Internet. Do it only if you can control the firewall (so it may accept only your selected IPs) and/or if you can change the port your DB server listens to (in order to avoid the port-discovery bots hammering your server and by any chance getting hacked).

But to be honest, without knowing why you want/have to split your services, I can't give you any proper advice. So please give us more info according to the above questions.
thedinh
i'm using 2 free host and control host by Cpanel 11
i don't how to config and code.
mindfox
thedinh wrote:
i'm using 2 free host and control host by Cpanel 11
i don't how to config and code.

I really have the feeling that something is missing...

In your 1st post, you state that *your* code runs on php.
Now you say that you don't know how to code or how to perform any configuration changes.
My best bet is that you want to use a ready made program coded in php, which requires a db (mysql if my guess is correct? ).
So, what is the name (and if you can, the url to check it out) of that php solution?
Also, you need to check the FAQs of your free hosting providers and see if they allow you to have DB access outside their network (which I seriously doubt it, as most of them do not allow external access to the DB server).
rvec
mindfox wrote:

Also, you need to check the FAQs of your free hosting providers and see if they allow you to have DB access outside their network (which I seriously doubt it, as most of them do not allow external access to the DB server).
Frihost does, just in case frihost is hosting the mysql database...
thedinh
ok, i will chek out my host's rules. thanks for your support.
rayxzero
rvec wrote:
mindfox wrote:

Also, you need to check the FAQs of your free hosting providers and see if they allow you to have DB access outside their network (which I seriously doubt it, as most of them do not allow external access to the DB server).
Frihost does, just in case frihost is hosting the mysql database...


If that the case you should try putting a middle server page or webservice that get a data from DB within host B to be accessed from host A. This is applicable if HOST B have a WEB SERVER also. Very Happy
Fire Boar
rayxzero wrote:
rvec wrote:
mindfox wrote:

Also, you need to check the FAQs of your free hosting providers and see if they allow you to have DB access outside their network (which I seriously doubt it, as most of them do not allow external access to the DB server).
Frihost does, just in case frihost is hosting the mysql database...


If that the case you should try putting a middle server page or webservice that get a data from DB within host B to be accessed from host A. This is applicable if HOST B have a WEB SERVER also. Very Happy


I would be very wary of this: unless you have a good security protocol between the two hosts, this is not advisable because performing a query would involve having the data transferred via HTTP. That's bad because other people could look at the web page, or pretend to be the host. So make sure the data coming back is encrypted, and that the query is also encrypted.

Even then, it's not a great idea because it uses up more resources: waiting for the remote host to process a full HTTP request each time you want to make a database query.
riccopt
it depends if you can only connect to the DB locally or if you can connect to it remotely... some servers only allow local connections to keep their servers safer...
rayxzero
Fire Boar wrote:
rayxzero wrote:
rvec wrote:
mindfox wrote:

Also, you need to check the FAQs of your free hosting providers and see if they allow you to have DB access outside their network (which I seriously doubt it, as most of them do not allow external access to the DB server).
Frihost does, just in case frihost is hosting the mysql database...


If that the case you should try putting a middle server page or webservice that get a data from DB within host B to be accessed from host A. This is applicable if HOST B have a WEB SERVER also. Very Happy


I would be very wary of this: unless you have a good security protocol between the two hosts, this is not advisable because performing a query would involve having the data transferred via HTTP. That's bad because other people could look at the web page, or pretend to be the host. So make sure the data coming back is encrypted, and that the query is also encrypted.

Even then, it's not a great idea because it uses up more resources: waiting for the remote host to process a full HTTP request each time you want to make a database query.


Some popular website now use this kind of http request method, like Facebook they are using webservices (restfull webservices i think to expose data from other), but in every request they should need a security key to get a data from the server.

But still it is more safer if you just access the db locally within the server. Very Happy
Fire Boar
I think the OP said that he's connecting to one database from two different hosts.
rayxzero
Just like the other said, it is possible if the database server ip and port is open or accessible by the 2 hosts.
Related topics
Slow Server ?
about database in settings.php
Phpnuke/mysql database help needed
PHP script has MSQL access denied
phpBB - Installation Tutorial
news system with login for more than 1 user.
Database information from Frihost!
Accessing mysql database thru software on local machine
Problems with SQL and Frihost...
Database connection class!
MySQL wont let me connect.
how to connect database through php
404 error
Mysql
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.