Solved

Joining tables in different mySQL databases on same server, different instances

Posted on 2013-12-02
7
199 Views
Last Modified: 2015-03-02
We have an application that uses two instances of mysql, running on two different ports on the same server, say 4510 and 4511.  Table "A" has transaction details and a user number, Table "B" (on 4511) has user details.  I need to simply join the two tables to provide all of the transaction details and the associated user name.  Apparently if these two databases were on the same mysql port, this would be pretty simple.  However, I'm not sure how to make it work in this case.

The only thing I've found so far relates to using a federated storage engine and federated table.  Is this the correct (only?) way to do what I need to do?
0
Comment
Question by:Chuck Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 

Author Comment

by:Chuck Brown
ID: 39692549
Sorry, joining two tables isn't the real problem.  Joining two tables in two different databases residing in two different databases that run under two different ports on the same server is the issue.  Thanks for trying!
0
 
LVL 35

Accepted Solution

by:
gr8gonzo earned 500 total points
ID: 39692553
Federated storage engine is the only way to do it with native MySQL functionality, but it's not the only way. Honestly, I would likely use some kind of intermediate scripting / programming language to pull the data separately and join it together.

For example, if you were using a .NET language, it would be trivial to create the two separate connections, then pull all the data into separate DataTable objects (optionally use a DataSet object to join them together) and go from there. The same thing could be done in a scripting language, like PHP.
0
 
LVL 35

Expert Comment

by:gr8gonzo
ID: 39692562
The only downside to the scripted approach is that the final, joined data exists within the scope of the application that did the joining, so that might be good or bad depending on your goals.
0
Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

 

Author Comment

by:Chuck Brown
ID: 39692575
Is there a downside to using the Federated Storage Engine?
0
 

Author Comment

by:Chuck Brown
ID: 39692593
virastar,

Thanks.  That may be closer, I'm not sure.  The end result of that solution is (apparently) to grant access between the databases, but doesn't say how that is to be done, nor how to actually do a query between the two once permission is granted.
0
 
LVL 35

Expert Comment

by:gr8gonzo
ID: 39692609
@virastar - that article uses the intermediate programming/scripting language approach that I mentioned, but pushing the data back into temp tables is likely slower than just using the in-memory data.

@clbrownjr - Aside from initial setup, no, there's no real downside. On the backend, it's technically doing the same thing - it's just using the MySQL client as the intermediate piece instead of a separate application. If you're good with enabling the federated storage, then it should be a fine solution.

Just to set expectations, remember that no matter what you do, you're dealing with two different, separately-optimized tables, so the solution will always be slower than using a single instance containing both tables.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
This tutorial will show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question