Solved

Replicate data from one MySQL DB to another

Posted on 2011-02-22
4
254 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 78

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 78

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

739 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