Solved

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

Posted on 2013-12-02
7
193 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

821 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