MySQL(配置主从)

  1. 【MySQL(配置主从)】环境准备
    • 192.168.32.130 --主库
    • 192.168.32.131 --从库
  2. 主库my.cnf 增加以下配置
log-bin=mysql-bin server-id=123

  1. 从库my.cnf 增加以下配置
server-id=124

  1. 主库上执行SQL
CREATE USER 'repl'@'192.168.32.%' IDENTIFIED BY '123456'; GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.32.%'; SHOW MASTER STATUS;

  1. 从库上执行SQL
CHANG MASTER TO MASTER_HOST='192.168.128.130', MASTER_USER='repl', MASTER_PASSWORD='123456', MASTER_LOG_FILE='mysql-bin.000002', MASTER_LOG_POS=10368; START SLAVE; SHOW SLAVE STATUS;

  1. 验证主从同步功能

    推荐阅读