This recipe teaches you how to configure MySQL's master-slave replication to maintain mirror copies of your databases in near real time.
To replicate data, the master MySQL server records details about any changes that take place (inserts, updates, and so on) to a file known as the binary log. Each slave server connects to the master's system, reads the information from the log file, and then duplicates the change to maintain their own local copy of the database. Each slave server is responsible for itself, which means we can bring a slave down for maintenance without affecting the availability of the master. Once it comes back online, the slave resumes replication from where it left off.
Replication can be useful in many situations. For example, if a full copy of the database is maintained on a slave, you can swap out the master server with little effort for a failover or disaster-recovery situation. For environments where scalability and performance are a concern...