• Replication in Mysql


    --=======================================================
    --登陆本地服务器
    
    mysql --user=root --password=Auto@sql
    
    --=======================================================
    --切换数据库使用use
    
    use test;
    
    
    --=======================================================
    --创建数据库
    
    CREATE DATABASE DB1;
    
    --=======================================================
    --创建表
    
    CREATE TABLE TB1
    (
        ID INT NOT NULL AUTO_INCREMENT,
        NAME VARCHAR(200) NOT NULL,
        PRIMARY KEY(ID)
    )
    
    --=======================================================
    --停止Mysql服务
    
    sc stop mysql
    
    
    --=======================================================
    --启动mysql服务
    
    sc start mysql
    
    --=======================================================
    --在主机上创建复制用户
    
    CREATE USER repl_user;
    GRANT REPLICATION SLAVE ON *.* TO repl_user IDENTIFIED BY 'Auto@sql';
    
    
    --=======================================================
    --在主机上刷新和锁定表
    
    FLUSH TABLES WITH READ LOCK;
    
    --=======================================================
    --备份数据库
    
    mysqldump --user=root --password=Auto@sql --all-database>d:\b1.sql;
    
    --=======================================================
    --取消表锁定
    
    UNLOCK TABLES;
    
    --=======================================================
    --查看master状态
    
    SHOW MASTER STATUS\G;
    
    --=======================================================
    --在从服务器上创建slave
    
    change master to
    master_host='192.168.25.162',
    master_user='repl_user',
    master_password='Auto@sql',
    master_port=3306,
    master_log_file='sqlnode22-log-bin.000001',
    master_log_pos=106;
    
    --=======================================================
    --在从服务器上启动slave
    
    start slave;
    
    --=======================================================
    --在从服务器上查看slave状态
    
    SHOW SLAVE STATUS \G;
    
    如果master_log_file和master_log_pos与主服务器上一致,并且
    Slave_log_running=Yes 和Slave_SQL_Runing=Yes,则主从配置成功
  • 相关阅读:
    NVI模式
    C#----接口与多继承
    C#----接口与抽象类
    C#----接口的显式实现
    C# -- 继承规则
    MVC多层架构
    BootStrap2学习日记23---弹出对话框
    APP导航设计九法
    DevExpress Grid使用checkBox选中的方法
    遗漏的SQL语句
  • 原文地址:https://www.cnblogs.com/TeyGao/p/2818018.html
Copyright © 2020-2023  润新知