开发者

MySQL slave attaches production database name to new views

I have a slave database that bears a different name than it's production counterpart. (We'll call prod database and slave database_slave.)

When I run a mysqldump from the slave (which I do for making dev copies), two of the database views have the database name attached to them. I cannot use the dump file to create another copy without manually editing it.

If I run the same mysqldump from the production copy, everything comes out clean. So for some reason the slave has created these two views incorrectly. (The other four views were created before replication was established, which I believe explains the difference. I have confirmed replication is in sync.)

Snippet of the mysqldump from the slave:

/*!50001 VIEW `database_slave`.`view_company` AS select `database`.`company`.`id` A开发者_如何学CS `id`,
         `database`.`company`.`name` AS `name`,`database`.`company`.`state` AS `state`,

Same snippet of the mysqldump, but from production (nice and clean):

/*!50001 VIEW `view_company` AS select `company`.`id` AS `id`,
         `company`.`name` AS `name`,`company`.`state` AS `state`,

Can I fix this without having to dump from prod to the slave?

We are using replicate-rewrite-db option.


In replication setup slave databases (and all database objects) are expected to be called the same as on master server.


In case anybody comes searching for this, what I learned is that mysql views are built with the database name intact. Therefore when using the replicate-rewrite-db option to give the slave a different name, the views will NOT work correctly.

The only way I've found to work around this is to avoid using the replicate-rewrite-db flag.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜