修改主从机器的配置文件/etc/my.cnf
增加:
#my.cnf配置文件增加
log-bin=mysql-bin 开启log-bin日志
server-id=1 设置id
重启MySQL服务,登陆MySQL执行:
show variables like '%log_bin%';
查看log-bin on 已开启log-bin日志
grant replication slave on . to root@'172.29.4.10' identified by '123456';查看生成的授权信息:
show master status;

change master to master_user='root',\
master_password='123456',\
master_host='172.29.4.9',\
master_log_file='mysql-bin.000002',\
master_log_pos=316;
--master_log_file与Position相同,master_log_file与File相同
在data目录下生成授权信息 master.info
start slave;
show slave status\G;

在主服务器创建新数据库,登陆从服务器可以看见刚刚主服务器创建的数据库
主:

从:
