0

I want to query data from 2 different database server using mysql. Is there a way to do that without having to create Federated database as Google Cloud Platform does not support Federated Engine. Thanks!

Developer
  • 83
  • 1
  • 10

2 Answers2

1

In addition to @MontyPython's excellent response, there is a third, albeit a bit cumbersome, way to do this if by any chance you cannot use Federated Engine and you also cannot manage your databases replication.

  1. Use an ETL tool to do the work

Back in the day, I faced a very similar problem: I had to join data from two separate database servers, neither of which I had any administrative access to. I ended up setting up Pentaho's ETL suite of tools to Extract data from both databases, Transform if (basically having Pentaho do a lot of work with both datasets) and Loading it on my very own local database engine where I ended up with exactly the merged and processed data I needed.

Be advised, this IS a lot of work (you have to "teach" your ETL tool what you need and depending on what tool you use, it may involve quite some coding) but once you're done, you can schedule the work to happen automatically at regular intervals so you always have your local processed/merged data readily accesible.

FWIW, I used Pentaho's community edition so free as in beer

Javier Larroulet
  • 3,047
  • 3
  • 13
  • 30
0

You can achieve this in two ways, one you have already mentioned:

1. Use Federated Engine

You can see how it is done here - Join tables from two different server. This is a MySQL specific answer.

2. Set up Multi-source Replication on another server and query that server

You can easily set up Multi-source Replication using Replication channels

Check out their official documentation here - https://dev.mysql.com/doc/refman/8.0/en/replication-multi-source-tutorials.html

If you have an older version of MySQL where Replication channels are not available, you may use one of the many third-party replicators like Tungsten Replicator.

P.S. - There is no such thing in MySQL as a FDW in PostgreSQL. Joins across servers are easily possible in other database management systems but not in MySQL.

MontyPython
  • 2,906
  • 11
  • 37
  • 58