环境介绍:有两套mysql主从(A和B),现需求将A套的mysql从库恢复到B套的mysql主库和从库。执行过程以下:mysql
先将A套的mysql从库备份,传至B套服务器上sql
从库操做数据库
中止主从关系服务器
slave stop;ide
而后分别恢复B套的主和从的数据库blog
mysql -uroot -prootip
use dbnamessl
source /data/tmp/dbname_20141010.sqlci
从库连接主库的用户slave 密码slave (若是忘记了能够新建一个用户http://xficc.blog.51cto.com/1189288/1562168)get
主库 查询 FILE 及 Position 的值
show master status;
从库 配置
mysql> change master to
master_host='主库ip',
master_user='slave',
master_password='slave',
master_log_file='mysql-bin.000007', #主库 查出来的 show master status;
master_log_pos=7; #主库 查出来的 show master status;
而后执行 slave start;
##################################################################
查看主库状态
show processlist\G;
//state状态应该为Has sent all binlog to slave; waiting for binlog to be updated
查看从库状态
show slave status\G;
//Slave_IO_Running 与 Slave_SQL_Running 状态都要为Yes
show processlist;
//应该有两行state值为:
Has read all relay log; waiting for the slave I/O thread to update it
Waiting for master to send event