先建立同步账号
GRANT REPLICATION SLAVE,RELOAD,SUPER ON *.* TO slave@'192.168.30.57' IDENTIFIED BY '123456';
主 192.168.30.42
修改my.ini
server-id=1
log-bin=sync_log
binlog-do-db=test
binlog-ignore-db=mysql
SHOW MASTER status;
从 192.168.30.57
修改my.ini
server-id=2
replicate-do-db=test
replicate-ignore-db=mysql
STOP SLAVE;
CHANGE MASTER TO master_host = '192.168.30.42',
master_user = 'slave', --同步账号
master_password = '123456',--同步密码
master_log_file = 'sync_log.000003',--SHOW MASTER status查询结果
master_log_pos = 107;--SHOW MASTER status查询结果
start SLAVE;
如果不好使,在从服务器:reset slave;然后再执行:
STOP SLAVE;
CHANGE MASTER TO master_host = '192.168.30.42',
master_user = 'slave', --同步账号
master_password = '123456',--同步密码
master_log_file = 'sync_log.000003',--SHOW MASTER status查询结果
master_log_pos = 107;--SHOW MASTER status查询结果
start SLAVE;
如果:
Slave_IO_Running: Yes
Slave_SQL_Running: No
将binglog指针下移一个位置。
解决方案:
mysql> slave stop;
mysql> set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
mysql> slave start;