ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
教程1: [https://www.codenong.com/cs109246592/](https://www.codenong.com/cs109246592/) 教程2: 主 show master status \\G create user 'slave'@'127.0.0.1' identified by '123456'; grant all privileges on \*.\* to 'slave'@'127.0.0.1'; 从 change master to master\_host='127.0.0.1', master\_user='slave', master\_password='123456', master\_log\_file='mysql-bin.000003', master\_log\_pos=156; start slave; stop slave; show slave status\\ G mysql> CHANGE REPLICATION FILTER REPLICATE\_REWRITE\_DB = ((viai, f\_viai)); change master to master\_host='192.168.1.6',master\_user='slave',master\_password='123456', master\_log\_file='mysql-bin.000036',master\_log\_pos=557; 一、准备两台或两台以上装有 mysql 的服务器 修改 mysql 的配置文件: 主的 mysql 服务器: server\_id = 1 log-bin=mysql\_bin.log 从服务器: server\_id = 3   #(不能与主服务器的 id 相同) 二、主服务器操作 创建连接用户并授权: mysql 5.0 版本:grant replication slave on \*.\* to'slave'@'%' identified by '123456'; mysql 8.0 版本:create user'slave'@'%' identified by '123456'; # 创建用户              grant replication slave on \*.\* to'slave'@'%';  # 授权 flush privileges; 查看主服务器信息: show master status; ![](https://img.kancloud.cn/72/f4/72f4b4099e3f84c4c02dce66c8443f96_623x99.png) 三、从服务器操作 连接主服务器:change master to master\_host='172.17.0.4',master\_user='slave',master\_password='123456', master\_log\_file='mysql-bin.000002',master\_log\_pos=334;        start slave;           show slave status\\G ![](https://img.kancloud.cn/0b/7a/0b7aec64da787d7a19bd667fb8c6e367_550x467.png)  如果 Slave\_IO\_Running 和 Slave\_SQL\_Running 对应的值都是 yes 则说明主从布置成功。