<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="replication-formats">
      </a>
      19.2.1 Replication Formats
     </h3>
    </div>
   </div>
  </div>
  <div class="toc">
   <dl class="toc">
    <dt>
     <span class="section">
      <a href="replication-sbr-rbr.html">
       19.2.1.1 Advantages and Disadvantages of Statement-Based and Row-Based
Replication
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="replication-rbr-usage.html">
       19.2.1.2 Usage of Row-Based Logging and Replication
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="replication-rbr-safe-unsafe.html">
       19.2.1.3 Determination of Safe and Unsafe Statements in Binary Logging
      </a>
     </span>
    </dt>
   </dl>
  </div>
  <p>
   Replication works because events written to the binary log are
      read from the source and then processed on the replica. The events
      are recorded within the binary log in different formats according
      to the type of event. The different replication formats used
      correspond to the binary logging format used when the events were
      recorded in the source's binary log. The correlation between
      binary logging formats and the terms used during replication are:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      When using statement-based binary logging, the source writes
          SQL statements to the binary log. Replication of the source to
          the replica works by executing the SQL statements on the
          replica. This is called
      <span class="firstterm">
       statement-based
          replication
      </span>
      (which can be abbreviated as
      <span class="firstterm">
       SBR
      </span>
      ), which corresponds
          to the MySQL statement-based binary logging format.
     </p>
    </li>
    <li class="listitem">
     <p>
      When using row-based logging, the source writes
      <span class="firstterm">
       events
      </span>
      to the binary log
          that indicate how individual table rows are changed.
          Replication of the source to the replica works by copying the
          events representing the changes to the table rows to the
          replica. This is called
      <span class="firstterm">
       row-based
          replication
      </span>
      (which can be abbreviated as
      <span class="firstterm">
       RBR
      </span>
      ).
     </p>
     <p>
      Row-based logging is the default method.
     </p>
    </li>
    <li class="listitem">
     <p>
      You can also configure MySQL to use a mix of both
          statement-based and row-based logging, depending on which is
          most appropriate for the change to be logged. This is called
      <span class="firstterm">
       mixed-format logging
      </span>
      .
          When using mixed-format logging, a statement-based log is used
          by default. Depending on certain statements, and also the
          storage engine being used, the log is automatically switched
          to row-based in particular cases. Replication using the mixed
          format is referred to as
      <span class="firstterm">
       mixed-based replication
      </span>
      or
      <span class="firstterm">
       mixed-format
          replication
      </span>
      . For more information, see
      <a class="xref" href="binary-log-mixed.html" title="7.4.4.3 Mixed Binary Logging Format">
       Section 7.4.4.3, “Mixed Binary Logging Format”
      </a>
      .
     </p>
    </li>
   </ul>
  </div>
  <p>
   <b>
    NDB Cluster.
   </b>
   The default binary logging format in MySQL NDB Cluster
        8.4 is
   <code class="literal">
    ROW
   </code>
   . NDB Cluster
        Replication uses row-based replication; that the
   <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
    <code class="literal">
     NDB
    </code>
   </a>
   storage engine is incompatible
        with statement-based replication. See
   <a class="xref" href="mysql-cluster-replication-general.html" title="25.7.2 General Requirements for NDB Cluster Replication">
    Section 25.7.2, “General Requirements for NDB Cluster Replication”
   </a>
   , for more
        information.
  </p>
  <p>
   When using
   <code class="literal">
    MIXED
   </code>
   format, the binary logging
      format is determined in part by the storage engine being used and
      the statement being executed. For more information on mixed-format
      logging and the rules governing the support of different logging
      formats, see
   <a class="xref" href="binary-log-mixed.html" title="7.4.4.3 Mixed Binary Logging Format">
    Section 7.4.4.3, “Mixed Binary Logging Format”
   </a>
   .
  </p>
  <p>
   The logging format in a running MySQL server is controlled by
      setting the
   <a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
    <code class="literal">
     binlog_format
    </code>
   </a>
   server
      system variable. This variable can be set with session or global
      scope. The rules governing when and how the new setting takes
      effect are the same as for other MySQL server system variables.
      Setting the variable for the current session lasts only until the
      end of that session, and the change is not visible to other
      sessions. Setting the variable globally takes effect for clients
      that connect after the change, but not for any current client
      sessions, including the session where the variable setting was
      changed. To make the global system variable setting permanent so
      that it applies across server restarts, you must set it in an
      option file. For more information, see
   <a class="xref" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
    Section 15.7.6.1, “SET Syntax for Variable Assignment”
   </a>
   .
  </p>
  <p>
   There are conditions under which you cannot change the binary
      logging format at runtime or doing so causes replication to fail.
      See
   <a class="xref" href="binary-log-setting.html" title="7.4.4.2 Setting The Binary Log Format">
    Section 7.4.4.2, “Setting The Binary Log Format”
   </a>
   .
  </p>
  <p>
   Changing the global
   <a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
    <code class="literal">
     binlog_format
    </code>
   </a>
   value requires privileges sufficient to set global system
      variables. Changing the session
   <a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
    <code class="literal">
     binlog_format
    </code>
   </a>
   value requires
      privileges sufficient to set restricted session system variables.
      See
   <a class="xref" href="system-variable-privileges.html" title="7.1.9.1 System Variable Privileges">
    Section 7.1.9.1, “System Variable Privileges”
   </a>
   .
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    Changing the binary logging format
        (
    <a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
     <code class="literal">
      binlog_format
     </code>
    </a>
    system variable)
        was deprecated in MySQL 8.0; in a future version of MySQL, you
        can expect
    <code class="literal">
     binlog_format
    </code>
    to be removed
        altogether, and the row-based format to become the only logging
        format used by MySQL.
   </p>
  </div>
  <p>
   The statement-based and row-based replication formats have
      different issues and limitations. For a comparison of their
      relative advantages and disadvantages, see
   <a class="xref" href="replication-sbr-rbr.html" title="19.2.1.1 Advantages and Disadvantages of Statement-Based and Row-Based Replication">
    Section 19.2.1.1, “Advantages and Disadvantages of Statement-Based and Row-Based
        Replication”
   </a>
   .
  </p>
  <p>
   With statement-based replication, you may encounter issues with
      replicating stored routines or triggers. You can avoid these
      issues by using row-based replication instead. For more
      information, see
   <a class="xref" href="stored-programs-logging.html" title="27.7 Stored Program Binary Logging">
    Section 27.7, “Stored Program Binary Logging”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
