====== MySQL - Replication ======
===== Master =====
log-bin = /var/log/mysql/mysql-bin.log
binlog-do-db=exampledb
server-id=1
In addition, we allow remote locking tables and receiving calls from outside.
GRANT REPLICATION SLAVE ON *.* TO 'slave_user'@'%' IDENTIFIED BY ''; (Replace with a real password!)
FLUSH PRIVILEGES;
SHOW MASTER STATUS;
Result
+---------------+----------+--------------+------------------+
| File | Position | Binlog_do_db | Binlog_ignore_db |
+---------------+----------+--------------+------------------+
| mysql-bin.006 | 183 | exampledb | |
+---------------+----------+--------------+------------------+
1 row in set (0.00 sec) UNLOCK TABLES;
===== Slave =====
server-id=2
The rest of the things will be directly in the database. Some tutorials indicate that you can also here, too.
LOAD DATA FROM MASTER;
Do this if there is already some data.
SLAVE STOP;
CHANGE MASTER TO MASTER_HOST='192.168.0.100', MASTER_USER='slave_user', MASTER_PASSWORD='', MASTER_LOG_FILE='mysql-bin.006', MASTER_LOG_POS=183;
To see what this returns:
\h CHANGE MASTER TO
===== Summary =====
MASTER_HOST - Address of the master server
MASTER_USER - user
MASTER_PASSWORD - password
MASTER_LOG_FILE -
MASTER_LOG_POS -
START SLAVE;