Note: A backend developer here with little to no experience in setting up database servers and replication.
What needs to be done
Setup DB replication of an existing database with the following constraints:
- Replicate only a specific list of tables/views with different names in the replicated database.
- Change the name of the tables/views in the replicated database (during the replication process)
- Setup a user on the replicated DB with further restrictions with which only a set of table/view can be viewed/updated/deleted
Progress so far
I have already read the document here, however, I did not find anything concrete to help me move forward with all the use-cases I wish to support!
Use Case
Show only essential data to the external vendor.
PS: If there are any other approaches other than replication, would be happy to consider and implement that as well.
Best Answer
On the master host you have to add to the
[mysqld]
section of themy.cnf
:Master service should be restarted then.
You can rename the replica's database but you can't rename tables, views and other objects. If you want to avoid collisions between local and replicated objects you have to replicate all the objects into the different database.
On the slave host you have to add to the same section:
Slave service should be restarted too.
Next you have to make an initial copy of the data (remotely):
Next you have to create an empty target DB on the slave and fill it by dumped data:
Then you have to create the slave process on the slave host.
mdump.sql
file contains binlogfilename
andposition
in the header so you can copy and paste them:Now you can start the slave and check its state: