I have a production database called "master" that I want to replicate on another server under another name (call it "slave").
All worked fine until an ALTER TABLE statement was performed on the master server. Since then, the replication hung up and I get this error in the slave log:
[ERROR] Slave SQL: Error 'Table 'master.students' doesn't exist' on query. Default database: ''. Query: 'ALTER TABLE `master`.`students`
Well of course it does not exists since I told MySQL to rename "master" to "slave"! But it seems like MySQL decided not to rename the database in ALTER TABLE statements.
Here is an excerpt from my slave config.
server-id = 2
relay-log = /var/log/mysql/mysql-relay-bin.log
log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = slave
replicate-rewrite-db="master->slave"
-
Did you have a USE statement before it? Consider writing a bug at bugs.mysql.comRick James– Rick James2015年06月09日 00:37:44 +00:00Commented Jun 9, 2015 at 0:37
1 Answer 1
It turns out I was using MySQL Workbench and it does not output a "USE" statement in its DDL update scripts, also rewriting does not occur if you do not provide a use statement.
So adding USE master;
at the beginning of the script fixed it. Thanks!