Rabesh Lal Shrestha
Rabesh Lal Shrestha

Reputation: 304

how to access database from one website to another website

Hi I'm having problem with accessing database from one of my site to another..

I have one site say a.com and I want to replicate the database from this site to my another site say b.com...

I'm using Cpanel in both the sites. In site A.com, I have created a user with required privileges and also added the other website (b.com) in the access hosts..

Now to access a.com database from b.com, I can use the username and password I have created on a.com but I'm not sure what hostname should I use..

Website a.com use localhost as the hostname..what should I use with b.com..

Upvotes: 2

Views: 6381

Answers (4)

Rabesh Lal Shrestha
Rabesh Lal Shrestha

Reputation: 304

we can get data from another site by using $.getJSON function of jQuery

You can get detail information from http://api.jquery.com/jQuery.getJSON sites....

Upvotes: 0

uttam
uttam

Reputation: 589

if you can't connect to the database then it's better to develop some kind of api. Try this search api to use in external websites you might get some help.

Upvotes: 1

Quentin
Quentin

Reputation: 943142

Assuming:

  • the database is configured to be exposed on the network (if it is designed to be used only from the same machine it shouldn't be, UNIX sockets are preferred)
  • there is no firewall in the way
  • the database permissions table grants rights to users on the other server

… then it would be the ip address of the machine the database server is running on.

Upvotes: 1

Madara's Ghost
Madara's Ghost

Reputation: 174947

You should use a.com, or a decent IP address/domain name that will correctly direct the connection to the database.

However, do note you will need to configure the incoming server to accept the connection (i.e. port forwarding, firewall etc).

Upvotes: 0

Related Questions