O'Reilly logo

MySQL 8 Cookbook by Karthik Appigatla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

In this section, setting up of single slave is explained. The same principles can be applied to set up chain replication. Usually the backups are taken from the slave when setting up another slave.

Outline:

  1. Enable binary logging on the master
  2. Create a replication user on the master
  3. Set the unique server_id on the slave
  4. Take backup from the master
  5. Restore the backup on the slave
  6. Execute the CHANGE MASTER TO command
  7. Start the replication

Steps:

  1. On master: Enable binary logging on the master and set SERVER_ID. Refer to Chapter 6, Binary Logging, to learn how to enable binary logging.
  2. On master: Create a replication user. The slave connects to the master using this account:
mysql> GRANT REPLICATION SLAVE ON *.* TO 'binlog_user'@'%' ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required