How to declare variable in trigger with MySQL?

How often does the replication trigger in mysql?

  • I have just set up mysql replication on win 7 machines using WAMP server 2.2. The database has successfully replicated but i guess that happened at the time i set it up. Now if i change(add/update/delete) some values from the master, how long will it take for the change to show up in the slave? Or do i have to do the trigger that manually every time? Of course there must be some automatic process that updates the slaves asynchronously.

  • Answer:

    As Muhammad said, MySQL replication is usually instantaneous.  If the slaves are connected and up to date on the master, they receive replication events as soon as they happen.  There are two threads on the slave side that determine how up to date the slave is: IO thread - connects to the master, reads binary log information, writes locally to the 'relay-log' SQL thread - reads the relay-log and applies the events to the slave. Either thread could be stopped or started.  SHOW SLAVE STATUS\G on the slave will show you the status of both.

Jay Janssen at Quora Visit the source

Was this solution helpful to you?

Other answers

There should be no delay in a setup if both master and slave are connected on LAN (unless there are huge time taking UPDATEs/DELETEs). MySQL slave almost always connected to the master waiting for the events. Make sure the replication is not broken on your slave by issuing the command on your MySQL slave and look for the value in column Seconds_Behind_MasterSHOW SLAVE STATUS;

Muhammad Wasif

First make sure your replication is running. go to process list on slave and see if you see a process that is replicating. As others have mentioned, if your Master and slave both are on LAN, it should be instantaneous in  most common cases. But if you want to go into  detail you first we need to know if your replication is RBR (Row based)  or SBR (statement based) ; SBR is much faster than row based. Replication is a CPU intensive feature, if you have 7 slaves its going to take some toll on the master; look at the CPU usage and see whats happening; look at SHOW SLAVE STATUS output and you will see the seconds_behind_master value

Nishchay Shah

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.