MySQL applies these rules when various
CREATE ... IF
NOT EXISTS statements are replicated:
CREATE DATABASE IF NOT EXISTSstatement is replicated, whether or not the database already exists on the source.
CREATE TABLE IF NOT EXISTSstatement without a
SELECTis replicated, whether or not the table already exists on the source. This includes
CREATE TABLE IF NOT EXISTS ... LIKE. Replication of
CREATE TABLE IF NOT EXISTS ... SELECTfollows somewhat different rules; see Section 126.96.36.199, “Replication of CREATE TABLE ... SELECT Statements”, for more information.
CREATE EVENT IF NOT EXISTSis always replicated, whether or not the event named in the statement already exists on the source.
CREATE USERis written to the binary log only if successful. If the statement includes
IF NOT EXISTS, it is considered successful, and is logged as long as at least one user named in the statement is created; in such cases, the statement is logged as written; this includes references to existing users that were not created. See CREATE USER Binary Logging, for more information.
(MySQL 8.0.29 and later:)
CREATE PROCEDURE IF NOT EXISTS,
CREATE FUNCTION IF NOT EXISTS, or
CREATE TRIGGER IF NOT EXISTS, if successful, is written in its entirety to the binary log (including the
IF NOT EXISTSclause), whether or not the statement raised a warning because the object (procedure, function, or trigger) already existed.