1

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.com – Rick James Jun 9 '15 at 0:37
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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.