Solved

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

Posted on 2013-12-02
7
187 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
  • 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 34

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 34

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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

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 34

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

A procedure for exporting installed hotfix details of remote computers using powershell
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

911 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now