0

In MySQL, I have two different databases -- let's call them A and B.

Database A resides on server server1, while database B resides on server server2.

Both servers {A, B} are physically close to each other, but are on different machines and have different connection parameters (different username, different password etc).

In such a case, is it possible to perform a connection between a table that is in database A, to a table that is in database B of different servers?

If so, how do I go about it, programatically, in php? (I am using php, MySQLDB to separately interact with each one of the databases).

4
  • either read the manual page or one of 100500 similar questions linked at the right side of this page. Commented Apr 21, 2012 at 7:24
  • I wish there was a close reason "Pointless, lazy and leeching question" Commented Apr 21, 2012 at 7:26
  • some people can only learn by asking a question specific to how they want a question asked/answered. True they can get the same solution from another question but it won't click to them since its not 100% pertaining to their particular solution. Commented Apr 21, 2012 at 7:38
  • @YourCommonSense wat's the problem u have....i read all those before asking this question here...i didn't found the answer i was searching for.... Commented Apr 21, 2012 at 7:43

2 Answers 2

1

The only way I can think of, is by opening 2 separate connections (i.e. instantiate 2 PDO objects) with all the different parameters, use 2 queries to query all the data you need into PHP, and then work with that on PHP.

Sign up to request clarification or add additional context in comments.

3 Comments

I tried to connect by creating two PDO objects in php,but i got an error message "Access denied for user 'database name'@'ip address'(using password:'yes')"
@user1334095 if you have certain problem with connecting to some database, why on the earth you are asking another question? why don't you ask a question regarding this very particular problem?
@user1334095: Well, this means you typed the username or password wrong, or the user you attempted to gain access with doesn't have sufficient privileges. But that doesn't mean it won't work if you did it right.
0

You can make two separate MySQL connections in PHP, do two queries to the two tables, and then work with the results in PHP.

Another option, since the servers are physically close, is to setup the one or both servers to replicate the needed database/tables to each other. You can look here for more on MySQL replication: http://dev.mysql.com/doc/refman/5.6/en/replication.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.