主从出错手动恢复同步

1.首先停掉Slave服务:STOP SLAVE;
2.到主服务器上查看主机状态:
记录File和Position对应的值。
mysql> show master status;
+------------------+-----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+-----------+--------------+------------------+
| mysql-bin.000020 | 135617781 | | |
+------------------+-----------+--------------+------------------+
 
3.到slave服务器上执行手动同步:
mysql> change master to master_log_file='mysql-bin.000020', master_log_pos=135617781;
 
mysql> START SLAVE;
 
4.Slave_IO_Running与Slave_SQL_Running 显示Yes