mysql5.7 主从数据库操作命令

时间:2021-07-28 03:26:36

从库配置

server-id = 3
relay-log = slave-relay-bin
relay-log-index = slave-relay-bin.index
read_only=1
log-bin=master-bin

slave-skip-errors=1062,1053,1146 #跳过指定error no类型的错误
#slave-skip-errors=all #跳过所有错误

port=3306
basedir="G:/phpstudy/PHPTutorial/MySQL/"
datadir="G:/phpstudy/PHPTutorial/MySQL/data/"
character-set-server=utf8

//主库操作
show master status;

//从表命令操作

stop slave;

reset slave all;

change master to master_host='192.168.255.128', master_port=3306, master_user='root', master_password='password',
master_log_file='master-bin.000004', master_log_pos=880;

start slave;

show slave status \G;

ALTER USER 'root'@'localhost' IDENTIFIED BY password' PASSWORD EXPIRE;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;