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

前端之家收集整理的这篇文章主要介绍了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.f2er.com/mysql/433319.html

猜你在找的MySQL相关文章