Solved

Replicate data from one MySQL DB to another

Posted on 2011-02-22
4
249 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 76

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 76

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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

Fore-Foreword Today (2016) Maxmind has a new approach to the distribution of its data sets.  This article may be obsolete.  Instead of using the examples here, have a look at the MaxMind API (https://www.maxmind.com/en/geolite2-developer-package). …
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

705 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