gpt4 book ai didi

mysql - mySQL是否复制: Master DB Name has to be the same as the Slave DB name?

转载 作者:可可西里 更新时间:2023-11-01 07:01:50 26 4
gpt4 key购买 nike

我已将主数据库名称设置为 MDB,并且在从服务器中设置为 replicate-do-db=SDB <-- 这不起作用?但是当我将它设置为相同的数据库名称时,它就可以工作了。有没有什么解决方案可以在同一台服务器上设置 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

关于mysql - mySQL是否复制: Master DB Name has to be the same as the Slave DB name?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1587896/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com