I have set the Master DB Name as MDB & in the Slave server I set to replicate-do-db=SDB <-- this did not work? But when I set it up as the same DB name it works. Is there any solution out there to setup 1 master db with 2 different slaves but in the same server??
2 Answers
You need to specify the replicate-rewrite-db
option:
--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.
If you are only replicating certain databases, you will need to specify the replicate-do-db
. Note that the argument to this is the name of the database after the rename operation applied by replicate-rewrite-db
:
--replicate-do-db=db_name

- 14,100
- 15
- 78
- 114

- 348,265
- 75
- 913
- 977
-
3where do I put the replicate-rewrite-db code in the master side or slave side?? – hkshambesh Oct 21 '09 at 09:41
-
plzz define weather to include replicate-do-db with replicate-rewrite-db or not? – Syed Muhammad Zeeshan Feb 12 '15 at 10:19
MySQL Replication with different database names
Add the following to the logging and replication section of your MySQL configuration file (/etc/mysql/my.cnf), I inserted mine right above relay-log.
replicate-rewrite-db = db_1->db_2
Replace db_1 with the database's name being replicated from the remote master and db_2 with the destination database's name.
- Restart the MySQL server (
/etc/init.d/mysql restart
) - Access the MySQL shell (
mysql -h localhost -u root -p
) - Check the Slave status (
SHOW SLAVE STATUS\G
)

- 418
- 8
- 18