微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

mySQL Replication:主数据库名称是否必须与从属数据库名称相同?

我已将主数据库名称设置为MDB&在Slave服务器中我设置为replicate-do-db = SDB< - 这不起作用?但是,当我将其设置为相同的DB名称时,它可以工作.是否有任何解决方案来设置1个主数据库与2个不同的从属但在同一服务器?

最佳答案
您需要指定replicate-rewrite-db选项:

--replicate-rewrite-db=from_name->to_name

Tells the slave to translate the default database (that is,the one
selected by USE) to to_name if it was from_name on the master. Only
statements involving tables are affected (not statements such as
CREATE DATABASE,DROP DATABASE,and ALTER DATABASE),and only if
from_name is the default database on the master. This does not work
for cross-database updates. To specify multiple rewrites,use this
option multiple times. The server uses the first one with a from_name
value that matches. The database name translation is done before the
–replicate-* rules are tested.

如果您只复制某些数据库,则需要指定replicate-do-db.请注意,此参数是replicate-rewrite-db应用重命名操作后的数据库名称

--replicate-do-db=db_name

原文地址:https://www.jb51.cc/mysql/433319.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐