Skip to main content

Step 2 — Replication Configuration on Primaty Server

  • On Primary Server

    • install nano  
      sudo apt-get install nano
    • Edit my.cnf file
      sudo nano /etc/mysql/my.cnf

       

      [mysqld]
      server-id = 1
      log_bin = /var/log/mysql/mysql-bin.log
      binlog_format = ROW
      innodb_flush_log_at_trx_commit = 1
      sync_binlog = 1
    • Restart MySQL server
      sudo systemctl restart mysql
    • mysql -u root -p
    • CREATE USER 'replica_user'@'%' IDENTIFIED BY 'strongpassword';
      GRANT REPLICATION SLAVE ON *.* TO 'replica_user'@'%';
      FLUSH PRIVILEGES;
    • FLUSH TABLES WITH READ LOCK;
      SHOW MASTER STATUS;
    • +------------------+----------+--------------+------------------+-------------------+
      | File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
      +------------------+----------+--------------+------------------+-------------------+
      | mysql-bin.000007 |   291136 |              |                  |                   |
      +------------------+----------+--------------+------------------+-------------------+
    • UNLOCK TABLES;
    • Go to the temp folder and export the database