1.创建同步帐号,在主从机器都执行
grant all privileges on *.* to backup@'192.168.1.x' identified by '1234';
flush privileges;
2 修改my.cnf
主机
server-id=1
log-bin=...
从机
server-id=2
log-bin=...
3.重启数据库
4.进入主机数据库 mysql -uUser -pPasword
show master status 不为空 则可以使用
配置主机为从机的slave
change master to master_user='从机IP', master_user='backup',master_password='1234';
slave start;
show slave status\G;
5.进入主机数据库 mysql -uUser -pPasword
show master status 不为空 则可以使用
配置从机机为主机的slave
change master to master_user='主机IP', master_user='backup',master_password='1234';
slave start;
show slave status\G;
done