mysql8.0


---
本文用mysql8.0.16和8.0.17做主从复制

yum install mysql-comminuty-server

grep 'password' /var/log/mysql.log  //筛选临时密码

mysqladmin -p'临时密码' password‘new’

log-bin=mysql-bin

server-id=1

systemctl restart mysqld

create user 'repl'@'%' identified with navite_password by   '密码';

grant replication salve on *.* to 'repl'@'%';

flush privileges;

show master status;

mysqldump -uroot -p密码 -all-databases --master-data=1 > /root/all.sql

scp -r /root/all.sql root@从IP地址:/root

从:

yum install mysql-community-server

grep 'password' /var/log/mysql.log  //筛选临时密码

mysqladmin -p'临时密码' password‘new’

vi /etc/my.conf

service-id=2

mysql -h 主节点 -u用户 -p密码

show grants; //看授权

 

 

set sql_log_bin=0 //避免还原的时候生成大量的sql语句

source /root/all.sql;

 change master to 

master_host='地址,

master_user='用户‘,

master_password='密码',

master_port='端口‘;  //这里不加log_file是因为前面master

CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=825

start slave;

show slave status\G;

stop slave;
---

Author: Qianli
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source Qianli !
  TOC