3

I am preparing to make some changes to a database I manage and was unsure that what I wanted to do would replicate properly so I ran some tests in a test environment and it turns out they will but only as long as I do not run the commands from the MySQL Workbench.

For example if have a database named db_test and a table in that database named test_a having only a single column id and I try to execute this from the workbench: INSERT INTO db_test.test_a (id) VALUES (114);

I get the expected row in the master database, but it never replicates to the slave.

When I perform a SHOW SLAVE STATUS - it shows everything is fine, and current. If I then use a different SQL client such as SequelPro and insert another row the same way (but obviously a different id) it shows in the master and replicates to the slave.

This has me baffled, and concerned as I want to understand what the difference is so I can avoid performing actions that never replicate.

5
  • Are you sure you're connected to the master? Jan 8, 2015 at 2:13
  • Yes I double checked that.
    – dtrotzjr
    Jan 8, 2015 at 2:31
  • Replication is totally independent of any client that accesses the server. It makes absolutely no sense that data inserted by MySQL Workbench is treated differently than data inserted by another client. There must be something else that is wrong. Jan 8, 2015 at 7:59
  • Are you using replication filtering ( especially --replicate-do-db) on the slave? Jan 8, 2015 at 13:34
  • @MikeLischke I totally agree with you, but I also know that two clients can behave differently based on implicit behaviors of the client. So I am wondering if one of these two clients is doing something under the hood that I am not aware of. I need to know so that I can have confidence that the method I choose will replicate 100% of the time.
    – dtrotzjr
    Jan 8, 2015 at 16:30

1 Answer 1

3

If you have set --replicate-do-db on the slave to filter replication for database db_test, replication is filtered based on the default database, so make sure that you issue USE db_test. Your client may be working differently in this manner, or you may be issuing different statements between clients.

Using --replicate-do-db set to db_test on the slave, this will replicate:

USE db_test;
INSERT INTO test_a (id) VALUES (114);

but this will not:

USE other_db;
INSERT INTO db_test.test_a (id) VALUES (114);

To get replication to work regardless of the current default database, use --replicate-wild-do-table to configure the database and table to replicate or don't filter at all.

Also, make sure that you are connected to the Master database server.

2
  • I don't see that replicate-do-db is being set, but this behavior is consistent as though it has been set, and beginning with USE db_text; does allow replication to work from the workbench. So my guess is that Sequel Pro is implicitly doing a USE db_text; for me, whereas the MySQL Workbench is not. Does that seem like a rational conclusion? Thank you for the response, I knew there had to be a reason to the madness.
    – dtrotzjr
    Jan 8, 2015 at 16:26
  • Thinking more about this, It makes sense that when I select the database in the UI that it issues a USE db_name
    – dtrotzjr
    Jan 8, 2015 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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