Mysql – Replicate tables to different database name

MySQLreplication

Our QA environment has all it's database names suffixed with "test". For example dbname1 in production would have a counterpart dbname1test in QA. (This is largely to help protect against prod/qa configs getting mixed up).

There are a handful of tables I would like to replicate the actual production tables into QA. I'm not sure how I would go about telling it to say "replicate from dbname1 there to dbname1test there"

Is this even possible?

Best Answer

Yes, there is. Put this in your my.cnf file:

replicate-rewrite-db="dbname1->dbname1test"

See Replication Slave Options and Variables: replicate-rewrite-db