Mysql master-master replication

slave:
binlog_format="MIXED"
 
log-bin=mysql-bin
relay-log=relay-mysql
relay-log-index=relay-mysql.index
auto-increment-increment=2
auto-increment-offset=2
 
master:
binlog_format="MIXED"
 
log-bin=mysql-bin
relay-log=relay-mysql
relay-log-index=relay-mysql.index
auto-increment-increment=2
auto-increment-offset=1
 
 
 
SQL:
 
CREATE USER 'repl'@'192.168.1.%' IDENTIFIED BY 'repl';
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.1.%';
flush privileges;
 
CHANGE MASTER TO MASTER_HOST='172.16.0.92', MASTER_USER='repl', MASTER_PASSWORD='repl', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=120;
 
 
TEST SQL:
show variables like '$server_id%';
 
show master status;
show slave status;
 
[slave上执行]
start slave;
stop slave;
reset slave; 
 
参考: http://blog.csdn.net/heizistudio/article/details/8616997
原文地址:https://www.cnblogs.com/shevche/p/4632204.html