配置环境:
yum -y install wget vim net-tools
yum -y groupinstall “Development Tools”
wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
rpm -ivh mysql80-community-release-el7-1.noarch.rpm
yum -y install mysql-community-server
设置开机自启,默认关闭防火墙
一主一从:
1.配置文件:vi /etc/my.cnf-----server-id=21(本机IP后两位)----log-bin=xiewei26(自定义命名)
2.创建用户并且授权:
create user ‘DE’@‘192.168.163.128’ identified by “(haha.123)”;(IP填写本机IP)
grant replication slave on . to ‘DE’@‘192.168.163.128’;(replication slave是给从库添加复制权限,还可以添加写入删除等权限)
3.查看master状态和节点
show master status;
4.主库操作完成,进入从库
建立与主库的连接:
change master to
-> master_host=‘192.168.163.130’,
centos7mysql5.7数据库主从连接,一主一从,多主一从、master、slave
最新推荐文章于 2022-05-10 22:18:54 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)