mysql主从
1.创建授权用户
grant replication slave on *.* to 'mark'@'192.168.1.201' identified by '123456';
2.查看master主机的状态
show master status;(主要看文件名字(file),和位置 (Position))
3.重启从机数据库
systemctl restart mysql
4.从机连接主机
change master to master_host='192.168.1.200',master_user='mark' ,master_password='12345', master_log_file='mysql- bin-200.000004' ,master_log_pos=671;
参数说明:
master_host: 主机的ip
master_user : 主机授权的用户.
master_password : 主机授权时候填写的密码
master_log_file : 主机show master status;中的File
master_log_pos: 主机show master status;中的Position.5.启动slave
start slave
6.查看slave状态
show slave status \G;
IO YES
SQL_IO YES
7.故障排除.
如果出现1236错误
可以通过:
-
停止从机.
stop slave -
重置从机
reset slave -
启动从机
start slave

浙公网安备 33010602011771号