Name

CHANGE MASTER TO

Synopsis

CHANGE MASTER TO option[,  . . . ]
      MASTER_HOST = 'host'
      MASTER_USER = 'user'
      MASTER_PASSWORD = 'password'
      MASTER_PORT = port
      MASTER_CONNECT_RETRY = count
      MASTER_LOG_FILE = 'filename'
      MASTER_LOG_POS = position
      RELAY_LOG_FILE = 'filename'
      RELAY_LOG_POS = position
      MASTER_SSL = {0|1}
      MASTER_SSL_CA = 'filename'
      MASTER_SSL_CAPATH = 'path'
      MASTER_SSL_CERT = 'filename'
      MASTER_SSL_KEY = 'filename'
      MASTER_SSL_CIPHER = 'list'

Use this statement to change several properties regarding connections to the master MySQL server. Some of the variables relate to connecting to the server and some relate to master log files and the current position in the logfiles. This statement is run from the slave. If the slave is running, it may be necessary to use the STOP SLAVE statement before using this statement, and the START SLAVE statement afterward.

The following SQL statement sets several properties for this slave:

CHANGE MASTER TO
   MASTER_HOST='mysql.company.com',
   MASTER_PORT=3306,
   MASTER_USER='slave_server',
   MASTER_PASSWORD='password',
   MASTER_CONNECT_RETRY=5;

The log clauses for this statement are used to name the master logfiles and to provide the slave with the current position of the master logfiles. This may be necessary when first setting up a new slave or when a slave has been disabled for awhile. Use the SHOW MASTER STATUS statement to determine the current position of the master logfiles. Use the SHOW SLAVE STATUS statement to confirm a slave’s position for the related ...

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.