SQL Server and MySQL Syncing - mysql

I am working with a client who is syncing between SQL Server and MySQL containing the exact same schema and data. We want to centralize that data into one database. Other then performance and maintainability issues, what else is bad about the original design?

You can create a linked server instance in SQL Server, with the MySQL instance.
Despite being completely proprietary, one of the nice connectivity features offered in SQL Server is the ability to query other servers through a Linked Server. Essentially, a linked server is a method of directly querying another RDBMS; this often happens through the use of an ODBC driver installed on the server.
Refer This article : step-by-step process SQL Server Linked Server to MySQL.
Providing you grant the MySQL user you connect on behalf of proper permissions, you can write to the MySQL instance accouding to you. So you can update stored procedures to do an additional step to insert records into MySQL.
Much easier solution is to use commercial application - Omega Sync from Spectral Core
Omega Sync can compare and synchronize both database schema and table data. You can even synchronize data of heterogeneous databases (for example, compare your local SQL Server database with a MySQL replica on your web site - and synchronize all the differences in just a few minutes).

on the otherhand I think you've already mentioned what possible problems you may encounter when synchronizing 2 db at the same time aside from this two I think it would be the resources. since there are different RDBMS working for the application they would also have a separate resources for each, like when I update a particular record of a user it still needs to check on which resource does it really exist, but I love to hear more from other people out there this is really an interesting topic to discuss. ;)

Related

How to connect two different Mysql servers from one stored procedure in Mysql?

I have two Mysql databases on different servers.
I need to update the Server 2 database from Server 1, but both database tables structure is different. I have to create a stored procedure to connect both servers so I can make changes in the database.
I am not a MySQL expert, so I can't tell you exact specifics. I looked through guides and other questions to see how it can be done and it appears that exact same principle I used in other databases applies to MySQL.
You need to Setup a remote database connection. Usually in doing so you will specify a name for that database. This is the only tricky thing in your question because of few reasons. One of them being not all platforms, that the database is installed onto, seem to support external connections and the other is that you need to set the 2nd database up for remote connections. I found this guide/article explaining how to set it up, but you might need to look for another one that fits your setup.
When forming your query specify database name (that you specified in previous step) before table name. The rest of the query structure is the same, but bare in mind that large/complex joins across 2 servers might be slow without manual optimization. This answer shows what your queries should look like when you setup a remote database connection.

Query data from database for 2 different server

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!
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.
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
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.

Migrate data from one sql database to a mysql database on real time

I should migrate part of the service provided from one back-end to another.
Company A has an application that connects to a .Net server in windows with a Sql database. Company B has an application that does something very similar, but connects to a node js server in debian with a MySql database.
Initially some of the services of the application will be transferred from A to B. The structure of the two databases is similar, but not quite the same. The basis of the solution I am preparing is:
Copying current data from A to B (with appropriate modifications, since there are differences in tables).
Creating triggers for create, update and delete operations on database A, so that all changes on database A will be reflected in database B
Step 1 I have figured out mostly. There will be some work to be done so that changes in tables are adapted. I will be using navicat to export tables from db A into excel spreadsheets. These spreadsheets will be modified to fit the structure of db B and then imported into db B, keeping in mind table dependencies.
For step 2, as I mentioned, I was considering using triggers. As far as I have been reading about triggers, they would require both databases to be sql or both of them to be mysql, which is not the case. I also tried this article, but could not make it work (server A is windows and server B is linux, this article does not seem to work for this case).
Any idea / correction / lead to performing the task? I have been thinking and googling but without making anything work.
PS: I am not asking help in writing the actual queries or statements that will replicate / update data from A to B, only a general method that will work considering that the databases are of different languages (sql to mysql), in different servers of different OS (windows to debian), and are used by code of different languages (.net + C# to node js).
PPS: Altering the code in server A to execute queries in both server A and server B is not an option.
PPPS: In the title I mention real - time replication. That would be ideal, but in lack of an appropriate solution, replication in intervals of time is also an option, as long as it is reasonably correct. Triggers managed real - time transfer, but in the worst case I could have a cron job in server B fetch the data from A, as long as I can tell which data to handle.

Any way to synchronize 2 mysql databases?

Two machines, each running mysql, each synchronized to the other peer-to-peer. I do not want a master db replicated. Rather, I want two users to be able to work on the data offline (each running a mysql server on his machine) and then when reconnected synchronize to each other. Any way to do this with mysql? Any other database I should be looking at to accomplish this better than mysql?
Two-way replication is provided by various database systems (e.g. SQLServer, Sybase etc.) but there are always problems with such a set up.
For example, if the same row is updated at the same time on the two databases, which update wins?
If your aim is to provide a highly-available MySQL database, then there are better options than using replication. MySQL has a clustering solution (though I've not had much success with it) or you can use things like DRBD and heartbeat to provide automatic failover with no loss of data.
If you mean synchronous writing back and forth, this would cause serious data consistency issues. I think you may be referring to MySQL replication, wherein a master server sends its updates to one or more slave database servers, which can be queried.
As for "Other Database Options" SQLServer supports a fairly advanced "replication" process for synchronizing the data between two or more db's. Looks like MySql has something like this as well though.

How to create linked server MySQL

Is it possible create/configure MySQL for functionality like SQL Server's Linked Server?
If yes, would you please tell me how? I'm using MySQL 5.5.
MySQL's FEDERATED engine provides functionality similar to SQL Server's Linked Server (and Oracle's dblink) functionality, but doesn't support connecting to vendors other than MySQL. It's not clear from the question if you need the functionality to connect to vendors other than MySQL.
You might want to look into MySQL Proxy. This doesn't match the architecture of Linked Servers/dblink, but you can probably solve a similar set of problems that you would use Linked Servers/dblink to solve.
I am the developer of the MySQL Data Controller. Unfortunately, since we had lack of requests we have stopped development on it. The plugin was 100% functional with MySQL connecting to Oracle, MSSQL or MySQL.
Base on some requests, we had added back a blog and video about it :
http://www.acentera.com/mysql-datacontroller/
Regards,
Francis L.
Unfortunately you cannot link an entire MySQL database to another MySQL database like you can with MS SQL. However, you can link individual tables. A federated table is a local table you create that points to a table on another server.
You can run queries and stored procedures just like any other table. The two tables must have the same structure, except the Federated table uses a different database engine: Federated. If you make ANY changes to the structure of the remote table, you should re-create the local federated table.
The process is actually quite easy, here is an example: https://docs.oracle.com/cd/E17952_01/mysql-5.0-en/federated-use.html
In my experience, the time needed to create and implement this process is minimal, even when compared to linked servers. It should take you less than 30 minutes to get your first federated table working, after that its a 5 min process. Last item, when naming your federated table, I give it the same name as the remote table with a "federated_" in front, like federated_customer.
Also, store your federated table definitions as separate stored procedures so you can reuse them anytime you need to create the federated table again, AND so that other developers can see how you generated the federated table.
The MySQL Data Controller is a follow-on to the federated engine that allows connection to different database types, such as Microsoft SQL Server or Oracle. I am not sure how development is going, yet.
See: http://en.wikipedia.org/wiki/MySQL_DataController
or: https://launchpad.net/datacontroller