mysql 重新主从复制
2022/3/3 19:15:01
本文主要是介绍mysql 重新主从复制,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1.先进入主库,进行锁表,防止数据写入
mysql> flush tables with read lock;
2.进行数据备份
/usr/local/mysql/bin/mysqldump -uroot -p test> test.sql
3.查看master 状态
mysql> show master status; +------------------+-----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +------------------+-----------+--------------+------------------+-------------------+ | mysql-bin.000010 | 179567203 | | | | +------------------+-----------+--------------+------------------+-------------------+
4.停止从库
mysql> stop slave;
5.从库还原数据
mysql> source test.sql;
6.从新设置主从同步
CHANGE MASTER TO MASTER_HOST='172.16.2.216',MASTER_USER='repl',MASTER_PASSWORD='123456',MASTER_PORT=3306,MASTER_LOG_FILE='mysql-bin.000010', MASTER_LOG_POS=179567203;
7.从新开启主从同步
mysql> start slave;
8.查看主从同步状态
mysql> show slave status\G
9.主库解除锁
mysql> UNLOCK TABLES;
这篇关于mysql 重新主从复制的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2025-01-02MySQL 3主集群搭建
- 2024-12-25如何部署MySQL集群资料:新手入门教程
- 2024-12-24MySQL集群部署资料:新手入门教程
- 2024-12-24MySQL集群资料详解:新手入门教程
- 2024-12-24MySQL集群部署入门教程
- 2024-12-24部署MySQL集群学习:新手入门教程
- 2024-12-24部署MySQL集群入门:一步一步搭建指南
- 2024-12-07MySQL读写分离入门:轻松掌握数据库读写分离技术
- 2024-12-07MySQL读写分离入门教程
- 2024-12-07MySQL分库分表入门详解