mysql主从复制配置
保证主库和从库数据库数据一致
mysql主库MASTER配置(在my.cnf中加入以下配置):
log-bin=master-bin
binlog-do-db=test #需要同步的数据库名称
server-id=11
进行授权:
grant replication slave on *.* to 'repl'@'192.168.1.110' identified by 'repl' with grant option;
重启mysql
查看master状态
show master status;
mysql从库配置(在my.cnf中加入配置):
server-id=12
master-host=192.168.1.104
master-user=repl
master-password=repl
master-port=3306
replicate-do-db=test #需要同步的数据库名称
#停止slave
stop slave
#更改日志同步点
CHANGE MASTER TO MASTER_HOST='192.168.1.104',MASTER_USER='repl', MASTER_PASSWORD='repl',MASTER_LOG_FILE='master-bin.000002',MASTER_POSITION=1134;
#启动slave
start slave
#查看进程
show processlist;
#查看slave
show slave status;