Skip to content

Instantly share code, notes, and snippets.

@Linuxpizi
Last active April 1, 2020 09:57
Show Gist options
  • Select an option

  • Save Linuxpizi/5784d72c3cadf9690183ed65c431dccf to your computer and use it in GitHub Desktop.

Select an option

Save Linuxpizi/5784d72c3cadf9690183ed65c431dccf to your computer and use it in GitHub Desktop.
mysql主从搭建步骤
  1. 主节点创建账号
  -- 更新初始账号
  -- update mysql.user set password=password('ucloud.cn') where host='127.0.0.1' and user='root';
  -- flush privileges;
  -- 创建主从账号 192.168.179.1是从节点的IP
  create user 'repl'@'10.93.123.15' identified by 'ucloud.cn';
  grant replication slave on *.* to 'repl'@'192.168.179.1';
  flush privileges;
  1. 查看主节点信息
  show master status;

  1. 从节点配置主节点信息
  change master to master_host='10.93.123.15',master_port=3306,master_user='repl',master_password='ucloud.cn',master_log_file='mysql-bin.000002',master_log_pos=2183;
  1. 启动主备
  start slave;
  1. 查看结果
  show slave status\G
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment