MySQL Replication

Replication of MySQL databases is an easy thing if you disregard its complicated documentation. So this is a short howto on how to do it:

The my.cnf file of the Master server needs to have the following entries added:

server-id = 1
log-bin

The Slave server’s config should contain this:


server-id = 2
master-host = master.example.com
master-user = replication_user
master-password = replication_pass
replicate-do-db = database1
replicate-do-db = database2
log-warnings

After restarting both servers, the Master server needs some permissions being adjusted:


GRANT SUPER, REPLICATION CLIENT, REPLICATION SLAVE,RELOAD
ON *.*
TO replication_user@"%"
IDENTIFIED BY 'replication_pass';

… and this is for the Slave to start the replication process:

LOAD DATA FROM MASTER;

Really, it would be that simple if documentation wouldn’t make it that complicated and hard…

Author:

Leave a Reply

Your email address will not be published. Required fields are marked *