MySQL数据库

6个成员

备份后的同步操作步骤

发表于 2016-12-27 4458 次查看

--主机开两个窗口,一个进入mysql,一个是shell
--主机阻断写操作
mysql> FLUSH TABLES WITH READ LOCK;
Query OK, 0 rows affected (0.00 sec)
mysql> 
mysql> 
mysql> SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000002 |  1529881 | openser      | mysql,test       |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
--另外一个窗口导出主机数据库
mysqldump -u root -pyyzwchinese123 --opt -R youngchinese > youngchinese0822.sql
--刚才的窗口主机解锁
mysql> UNLOCK TABLES;
Query OK, 0 rows affected (0.00 sec)
mysql>
--打包数据文件到从机
drop database openser;
create database openser;
mysql -u root -p123456 openser < openser20121127.sql
--从机操作
SLAVE STOP;
reset slave;
CHANGE MASTER TO MASTER_HOST='192.168.21.26',
MASTER_USER='repl_user',
MASTER_PASSWORD='123456',
MASTER_LOG_FILE='mysql-bin.000002',
MASTER_LOG_POS=1529881;
start slave;
show slave status\G

发表回复
你还没有登录,请先登录注册