1.创建用户
create user 'sa'@'%' identified by '123456';
2.授权
grant all on *.* to 'sa'@'%';
3.在master机上为slave机添加一同步帐号
#GRANT FILE ON *.* TO 'sa'@'192.168.1.111' IDENTIFIED BY '123456';
grant replication slave on *.* to 'sa'@'192.168.1.111' identified by '123456';
flush privileges ;
#flush tables with read lock; //锁定数据库
server-id=1
log-bin=F:\mysql-bin
binlog-do-db=db
binlog-ignore-db=mysql
replicate-do-db=db
replicate-ignore-db=mysql
log-slave-update
重启服务器的mysql服务
show master status;
stop slave ;
change master to
master_host='192.168.1.2',
master_port=3306,
master_user='sa',
master_password='123456',
master_log_file='mysql-bin.000002',
master_log_pos=107;
start slave;
show slave status;
mysql> unlock tables;
Slave SQL错误导致同步卡住的一种处理方法
mysql>slave stop;
mysql>set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
mysql>slave start;
mysql-bin.000001 107
配置完毕保存后,增加了master.info与relay-log.info等文件。
停止MYSQL服务,删除data目录下除数据库外的所有文件, master.info和relay-log.info两文件必须删除。
注意:master修改my.ini时,master.info和relay-log.info必须删除重启服务。
create user 'sa'@'%' identified by '123456';
2.授权
grant all on *.* to 'sa'@'%';
3.在master机上为slave机添加一同步帐号
#GRANT FILE ON *.* TO 'sa'@'192.168.1.111' IDENTIFIED BY '123456';
grant replication slave on *.* to 'sa'@'192.168.1.111' identified by '123456';
flush privileges ;
#flush tables with read lock; //锁定数据库
server-id=1
log-bin=F:\mysql-bin
binlog-do-db=db
binlog-ignore-db=mysql
replicate-do-db=db
replicate-ignore-db=mysql
log-slave-update
重启服务器的mysql服务
show master status;
stop slave ;
change master to
master_host='192.168.1.2',
master_port=3306,
master_user='sa',
master_password='123456',
master_log_file='mysql-bin.000002',
master_log_pos=107;
start slave;
show slave status;
mysql> unlock tables;
Slave SQL错误导致同步卡住的一种处理方法
mysql>slave stop;
mysql>set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
mysql>slave start;
mysql-bin.000001 107
配置完毕保存后,增加了master.info与relay-log.info等文件。
停止MYSQL服务,删除data目录下除数据库外的所有文件, master.info和relay-log.info两文件必须删除。
注意:master修改my.ini时,master.info和relay-log.info必须删除重启服务。