Solved

Replicate data from one MySQL DB to another

Posted on 2011-02-22
4
251 Views
Last Modified: 2012-05-11
Hi,

I have two servers, hosted by different companies.  Both running MySQL.  I was wondering if there's a script that could run automatically that would transfer all of the data in the DB from one server over to the other.  Preferable something that ran automatically, like every 4 hours.  The table structure would be the same on both servers.

Thanks
0
Comment
Question by:Rush_2112
  • 2
4 Comments
 
LVL 6

Expert Comment

by:Ferrosti
ID: 34952100
It depends on how you need to handle your data. What is the purpose of this scenario?
Usually one would go for a binary log and apply it to the second server (master/slave setup).
0
 
LVL 77

Expert Comment

by:arnold
ID: 34952205
Do you have direct access to the mysql servers?
I.e. you would have an application/script running locally that will connect to each mysql server and perform the select/if exists update else insert into the other.
You can configure the frequency within your local system as well as add the logic to speedup the process by not retrieving unchanged data unnecessarily.
0
 
LVL 1

Author Comment

by:Rush_2112
ID: 35072410
Both servers are on shared hosting plans, so  I don't know if I have the kind of access you're talking about.  I was hoping there would be a msysql script that could auto-run.
0
 
LVL 77

Accepted Solution

by:
arnold earned 500 total points
ID: 35072980
In the scenario you describe, you can not without using an external process i.e. on your local computer you setup a script that will access a special PHP page on one host to get the data and then use a special php on the other host into which you will insert the data.

I'd think most hosting firms include access to phpmyadmin that has the ability to export backup the datatabase.  Using phpmyadmin you can then import/restore the database on the other host.

You could as part of access to your php page trigger checks to the other to perform replicative tasks.
i.e. a php request is received. and a response is provided instead of the PHP exiting, it will query the remote site and further process data.  note that this will increase the load on your system.  Note futher, that your hosts may prevent outgoing requests from the web servers which is what is needed from one to be able to access the other.

0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

776 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