mysql报错:he slave I_O thread stops because master and slave have equal MySQL server UUIDs;

问题描述

在主从复制中设置从库时报错:

Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work.

原因分析

为了模拟两台服务器,我直接复制了一个虚拟机,导致主库和从库的服务器UUID相同,从库会停止I/O线程以防止数据不一致。

解决方案

修改从库的UUID:

  1. 退出MySQL服务
  2. 修改auto.cnf中的server_uuid

vim ./var/lib/mysql/auto.cnf

  1. 重启mysqld

systemctl restart mysqld

  1. 重新登录MySQL

mysql -uroot -p1234

  1. 建立从库与主库的连接

change master to master_host='192.168.49.129', master_user='xiaoming', master_password='1234', master_log_file='mysql-bin.000001', master_log_pos=441;

  1. 启动从库

start slave;

  1. 查看从库状态

show slave status;看到如下状态即为成功
mysql报错:he slave I_O thread stops because master and slave have equal MySQL server UUIDs;_第1张图片mysql报错:he slave I_O thread stops because master and slave have equal MySQL server UUIDs;_第2张图片
mysql报错:he slave I_O thread stops because master and slave have equal MySQL server UUIDs;_第3张图片

你可能感兴趣的:(MySQL,mysql)