3

Can someone tell me how to prevent the following commands

 DROP TABLE <tbl-name>;
 TRUNCATE TABLE <tbl-name>;

from being replicated to slaves?

RolandoMySQLDBA
  • 185,223
  • 33
  • 326
  • 536
JSaleem
  • 31
  • 1
  • 5

1 Answers1

4

Disable binary logging in your session, drop the table, and enable binary logging.

SET sql_log_bin = 0;
DROP TABLE IF EXISTS ... ;
SET sql_log_bin = 1;

This works because if the Slaves do not see the DROP TABLE command registered in the Master's binary logs, it cannot run the DROP TABLE.

I have recommended using SET sql_log_bin = 0; before in my earlier posts

Give it a Try !!!

RolandoMySQLDBA
  • 185,223
  • 33
  • 326
  • 536