I know this question is similar to a previously answered question such as
How to compare data between two table in different databases using Sql Server 2008?
Compare two identical tables MySQL
But my concern here is, what if the two databases are in DIFFERENT locations? How would the SQL query look like?
To clarify, I have two MySQL servers, let's name the first server MONITOR, and the second server SNAPSHOT. Server MONITOR is used and maintained by a third party inventory management software. Server SNAPSHOT is my custom MySQL server that stores MONITOR's key tables and makes comparisons. Both of the servers have the same database named INVENTORY and a table named HARDWARE.
The SQL command in the above two links is exactly what I am striving for, however, since the databases are on two different servers, both requires different username/logins, which makes the SQL command fails to execute, and I'm seeking if there's a solution to this.
Also, another question being, in the case of both tables having large amounts of data (say over a million entries), would it be recommended for me to dump the MONITOR's table into SNAPSHOT's database first, and run the comparison query on the SNAPSHOT server?
PS: I would like both a PHP/PDO and a SQL solution, just to compare which method is much suited for a large scale process, if possible.
Questions that people might ask:
Q: Why don't you make both databases on MONITOR?
A: Because we wouldn't want if MONITOR goes down, the platform which uses SNAPSHOT's comparison goes down with it. Also, since MONITOR is generated and maintained by a third party software, we would like to interact as little as possible with it.
Q: Can't you write a trigger when MONITOR's data got updated and forward that to SNAPSHOT?
A: As mentioned above, we prefer not to touch the database generated by the third party to prevent possible errors/corruptions.