Mysql基础——主从MySQL手动同步

mysql 主从数据同步失败手动同步数据的方法

 

进入master执行

1、锁表

  • flush tables with read lock;

 

2、导出备份数据

  • mysqldump -u root -p test1 > /tmp/mysql.sql

 

3、查看主库状态记录偏移量position的值

  • show master status;

 

4、将备份数据文件发入到从库服务器

  • scp /tmp/mysql.sql root@192.168.10.101:/tmp

 

5、进入从库执行, 停掉从库同步

  • stop slave;

 

6、执行备份文件

  • use database;
  • source path/mysql.sql;

 

7、设置从库同步

  • change master to master_host='192.168.10.100',master_port=3306,master_user='repl',master_password='Qwe123!@#',master_log_file='mysql-bin.000001',master_log_pos=0;

 

8、开启从库同步

  • start slave;

 

9、查看从库状态

  • show slave status;

 

10、打开master表

  • unlock tables;

posted on 2024-12-05 10:50  gkhost  阅读(47)  评论(0)    收藏  举报

导航