Replication enables data from one MySQL database server (the master) to be replicated to one or more MySQL database servers (the slaves). Replication is asynchronous – slaves need not be connected permanently to receive updates from the master. This means that updates can occur over long-distance connections and even over temporary or intermittent connections such as a dial-up service. Depending on the configuration, you can replicate all databases, selected databases, or even selected tables within a database.

mysql replication


How To Set Up Database Replication In MySQL:

Configure master (/etc/mysql/my.cnf):

This settings will be available after a mysql restart.

Log into the MySQL shell and create a user with replication privileges:

This wil create a user with replication privileges, with access from slave database,

In this moment we need a database dump (a copy of databasetest). This can be achived by mysqldump, mysqlhotcopy, load data from master (on slave) or just tar.gz the database files. Each method will be later discussed.

Configure slave (/etc/mysql/my.cnf):

Stop mysql server:

Copy database to slave machine.

Start mysql server:

Check slave status:

Look for this fields:

this mean that the replication is working!



“auto-increment-increment” and “auto-increment-offset” will be later explained.



MySQL replication – master slave schema
Tagged on:         

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.