MySQL Migration / Merge Script (Linux)

There are many ways of migrating MySQL data from server to server and its just essential to use mysqldump or any other tools to do the task for you.

The simplest way to do this is via mysqldump (from source) then mysql (into target).

However, in my case I have an already existing database with data and I need to append later data into this database from a more recent mysql data source.

This script will help you accomplish that.

It has simplified the process:
– mysqldump data from source
– import data into target
– will fetch all tables from source and attempt to insert them into the target.
– will only process one table at a time

This works best for database architectures that implement replication. However, ensure that the target slave must be stopped first before running this script to prevent problems due to data inconsistencies.

A limitation of this process is that it is one-way and not bi-directional.

Copy the source-code and paste it into a file. ie. migrate.sh

Tested using the following:
– Centos Linux 7
– MySQL 5.0 Server
– MySQL 5.5 Client

Note:
– Does not work with MySQL 5.0 Client

Let the others know about this Rant
  • Print
  • Facebook
  • Twitter
  • LinkedIn
  • Plurk

About Christian Noel

Hi, I'm Cris! I'm interested in anime, programming and photography. My profession is programming and am mostly focused in web development. I've been programming since College. What inspired me to go to programming was because I was so into the gaming industry and I wanted to create my own game.
This entry was posted in Techy Thoughts and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *