Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does mySQL Replication: Master DB Name has to be the same as the Slave DB name?

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??

like image 539
hkshambesh Avatar asked Oct 19 '09 10:10

hkshambesh


People also ask

How does master master replication work in MySQL?

Replication enables data from one MySQL database server (known as a source) to be copied to one or more MySQL database servers (known as replicas). Replication is asynchronous by default; replicas do not need to be connected permanently to receive updates from a source.

What is MySQL master-slave replication?

MySQL replication is a real-time mechanism that automatically copies or replicates data from one server to another backup server. Database administrators can use the master-slave replication procedure to replicate or copy data from multiple servers at the same time.

Which MySQL utility copies the master instance to a slave instance on the same host?

MySQL replication is a process that enables data from one MySQL database server (the master) to be copied automatically to one or more MySQL database servers (the slaves).


1 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
like image 78
James McNellis Avatar answered Oct 30 '22 21:10

James McNellis