mysql主从设置

主库配置

[mysqld]

server-id = 1
log_bin = /home/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M

grant replication slave on *.* to 'ruobbo_slave'@'%' identified by '123456';

show master status;

文件名和行数字对应下面从库复制时sql里的值

从库配置

[mysqld]
server-id = 2
log-bin=relay-bin
relay-log-index = slave-replay-bin.index

change master to master_host='192.168.1.55',master_user='ruobbo_slave',master_password='123456',master_log_file='mysql-bin.000001',master_log_pos=63840458;

reset slave;

start slave;

show slave status\G

测试在主库新增加一个条数据,看从库是否同步

关闭从库 stop slave;

删除主从复制

change master to master_host=' ';

猜你喜欢

转载自blog.csdn.net/qq_30920479/article/details/103834383