docker-mysql主从复制失效

Master Slave 复制错误
Slave_IO_Running:Yes
Slave_SQL_Running:NO

Slave_IO_Running: No
Slave_SQL_Running: Yes

#在Slave库上查看状态
mysql> show slave status\G
Slave_IO_Running: No
Slave_SQL_Running: Yes

#回到宿主机重启master库:docker restart mysql-master
mysql> show master status;
±-----------------±---------±-------------±-----------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
±-----------------±---------±-------------±-----------------+
| mysql-bin.000006 | 988 | | |
±-----------------±---------±-------------±-----------------+
#到slave库

mysql> stop slave;
mysql> change master to master_host='172.16.100.2',master_port=3306,master_user='repl',master_password='rep123',master_log_file='mysql-bin.000006',master_log_pos=988 ;
mysql> start slave;
mysql> show slave status\G

#结果
Slave_IO_Running: Yes
Slave_SQL_Running: Yes

#进入mysql主库容器,设置远程访问授权
GRANT REPLICATION SLAVE ON . TO ‘mysql’@’%’ IDENTIFIED BY ‘weikaixxxxxx’;
格式:GRANT REPLICATION SLAVE ON . TO ‘新开帐号’@’%’ IDENTIFIED BY ‘新开帐号密码’;
#刷新mysql用户权限相关表
FLUSH PRIVILEGES;
#查看是否添加成功
select host,user from mysql.user;

你可能感兴趣的:(数据库)