Domanda

I have 2 servers with MySQL master-master replication set.
When I run an INSERT/UPDATE query from a PHP script on any of the servers it is replicated just fine on the other server.

Anyway, this won't happen when I run an UPDATE from a bash script: the value of a field will be updated only on the server where I run the bash script and won't be replicated on the other one.

Any ideas on why the replication won't work from a BASH script?

This is how a mysql update that only updates the local records looks like:
mysql -B -N -u $USER -p$PASSWORD -h $HOST -e "UPDATE $DATABASE.$TABLE SET Status='-1' WHERE Id=$ID"

È stato utile?

Soluzione

I suppose you have REPLICATE_DO_DB set. Check it with SHOW SLAVE STATUS. It's a bit tricky: if you have it to replicate only foo database and you do something like this:

use bar; -- or even without it
UPDATE foo.table SET Status='-1' WHERE Id=69;

than it'll NOT be replicated. Make sure you use the database that you want to replicate.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top