Skip to content

Instantly share code, notes, and snippets.

@githubutilities
Created October 1, 2015 10:29
Show Gist options
  • Select an option

  • Save githubutilities/15814a8305900f148185 to your computer and use it in GitHub Desktop.

Select an option

Save githubutilities/15814a8305900f148185 to your computer and use it in GitHub Desktop.
MySQL Master Slave Setup

MySQL Master Slave Setup

Master-slave replication keeps the data in sync from master to slave.

Master-slave MySQL servers are typically use master for writing data and slave for reading data so the changes that we make are reflected into slave serversin realtime. You can also use master for reading data while using slave for writing data to different tables. For more detail, please refer to here.

Please refer to MySQL Official Doc to set up MySQL replication.

  • config your master, restart your master
  • config your slave
  • create user for replication
CREATE USER 'root'@'%' IDENTIFIED BY 'password'
GRANT REPLICATION SLAVE ON *.* TO 'root'@'%'
  • obtain master binary log coordinates using SHOW MASTER STATUS
  • config your master in your slave using CHANGE MASTER TO ... and START SLAVE

Data Transfer

  • export -- mysqldump
  • import -- mysql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment