这里用的大版是MYSQL8,有些个别语法以实战为准
先在局域网中进行测试
主:192.168.1.194
从:192.168.1.164
主数据中打开/etc/my.cnf
[mysqld]
server-id = 1(这个原来下面有),如果是虚拟机克隆过去的注意这里,改成2也不行,后来才发现下面有

可能的错误是
Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it).
Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it).
当时用的是set global
mysql> set global server_id=2;
stop/start slave;(有网友反着写的可能是不同版本的吧)
改后是mysql> show variables like '%server_id';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id | 2 |
+---------------+-------+
1 row in set (0.01 sec)
UUID可能也会一样是虚拟机上克隆过去的,可能我这里194改成物理机后自动变了,记不清了
改的话在[/ww

本文详细讲述了在MySQL8中解决主从复制中服务器ID相同导致的问题,涉及my.cnf配置、server_id修改、UUID管理以及主从数据库的设置,包括grant权限和master设置,为读者提供了从测试、配置到解决常见问题的完整指南。
851

被折叠的 条评论
为什么被折叠?



