Solved

Replicate data from one MySQL DB to another

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

More Fun with XML and MySQL – Parsing Delimited String with a Single SQL Statement Are you ready for another of my SQL tidbits?  Hopefully so, as in this adventure, I will be covering a topic that comes up a lot which is parsing a comma (or other…
As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

895 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

12 Experts available now in Live!

Get 1:1 Help Now