mysql slave创建:mysqldump参数--master-data

在创建mysql从库时,通常我们先从主库dump下一份sql文件,再到mysql从库导入生成表,然后调用change master to开启从库,这时需要确定binlog文件和position位置。
那么如何确定position位置呢?

上网一搜,很多文章告诉你先到master库show master status查看postion。可是当你利用mysqldump导出主库,再到用show master status查看postion这段时间之间,master库早已变化了,这意味着postion位置也变化了。
准备的做法是从主库dump文件时,利用–master-data参数输出postion

官方文档地址:
https://dev.mysql.com/doc/refman/5.6/en/mysqldump.html

mysqldump –help解释:
–master-data[=#]
This causes the binary log position and filename to be appended to the output. If equal to 1, will print it as a CHANGE MASTER command; if equal to 2, that command will be prefixed with a comment symbol. This option will turn –lock-all-tables on, unless –single-transaction is specified too (in which case a global read lock is only taken a short time at the beginning of the dump; don’t forget to read about –single-transaction below). In all cases, any action on logs will happen at the exact moment of the dump. Option automatically turns –lock-tables off.
示例:

mysqldump -uroot -ptwm123 --master-data=1  huiyedb > /data/bak/dumpfile

这里写图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值