mysql主从复制
环境:
主机:centos7.6、mysql5.7
从机:centos7.6、mysql5.7
(1)修改主机的mysql配置文件
server-id=1
log-bin=/cxwww/server/mysql/5.7.28/data/mysql_bin
重启mysql:service mysql reload
(2)修改从机的mysql配置文件
server-id=2
重启mysql:service mysql reload
(3)主机授予从机复制权限
grant replication slave on *.* to "root"@"从机ip地址" identified by "主机mysql密码"
(4)从机指定主机相关参数
change master to master_host="主机ip地址",
master_user="root", master_password="主机mysql密码",
(5)开启从机io线程
start slave
(6)查看从机状态
show slave status
当结果中Slave_IO_Running和Slave_SQL_Running的值全为Yes时,主从数据库配置成功