MySQL Replication

Setting MySQL Master

  1. Modify my.cnf (usually located in /etc/mysql/my.cnf)
    1. Update bind-address entry from 127.0.0.1 to the regular IP
      • bind-address = 127.0.0.1
      • bind-address = 123.234.12.13
    2. Set server-id to 1
    3. Uncomment the line with log_bin
    4. Designate the database to be replicated on to the slave server
      • binlog_do_db = db_to_replicate
    5. Save my.cnf and restart mysql
  2. Grant privileges to the slave (mysql command line)
    • GRANT REPLICATION SLAVE ON *.* to ‘slave_user’@’%’ IDENTIFIED BY ‘password’;
    • FLUSH PRIVILEGES;
  3. ss

Setting MySQL Slave

  1. Modify my.cnf
    1. Set server-id to 2
    2. relay-log = /var/log/mysql/mysql-relate-bin.log (need to be added manually)
    3. log_bin = /var/log/mysql/mysql-bin.log
    4. binlog_do_db = <newdatabase>
  2. Set pw

– manzoor

Related Reading


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s