# Database Discussions > MySQL >  how to sync two mysql databases?

## temak82

Hello everyone,

I have a small problem ahead of me. I run a hosting company and am going to start offering syncing services to my clients. I am going to use DNS failover to monitor the main server and if that should go down, kick it over to the secondary server for minimal downtime. 

I will also be using rsync to update the necessary files to the second server. 

My question is, how would I go about setting something up that would automatically sync the necessary mysql databases? 

Here's how it would work right now:

1. I would modify the necessary config file for the rsync script to include the customers who paid for the service. It will only sync those accounts. These accounts are located in /home/acctname
2. The mysql dbs are located at /var/lib/mysql folder (you probably knew that), so, I could use rsync to just copy them over, but the hardest part is to actually apply the updates to the databases on the second server. How can I go about doing this?

Thanks for any help!

----------


## greenman

Hi

Does MySQL replication (http://www.databasejournal.com/featu...le.php/3355201) not do what you need?

----------


## temak82

Thanks for the link. I'll check it out.

----------


## jazcyk

Have a look at the program SQLyog at www.webyog.com.

Also read this:
http://www.webyog.com/faq/10_60_en.html

----------


## chigs20

It appears that you want a failover feature.

MySQL offers:

Replication: setup two hosts (1 master & 1 slave). All data is written to the master and the slave replicates the data.  Now if the master fails, the slave does NOT take over, but you do have a copy of all your data unharmed.
(You could create a few simple shell scripts where if the IP of the master fails, have the slave change IP address...)
http://dev.mysql.com/doc/refman/5.0/en/replication.html

Clustering: setup 3 or more hosts (1 server to manage the cluster, 1 master and 1 node). All data is written to the master then to the slave.  If the master fails then the node automatically takes over.
http://dev.mysql.com/doc/refman/5.0/en/ndbcluster.html

----------

