zoukankan      html  css  js  c++  java
  • MySql 主从同步 (库名不同)

    主库:192.168.1.250

    从库:192.168.1.199

    主库  my.ini

    # For advice on how to change settings please see
    # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
    # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
    # *** default location during install, and will be replaced if you
    # *** upgrade to a newer version of MySQL.
    
    [mysqld]
    
    # Remove leading # and set to the amount of RAM for the most important data
    # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
    # innodb_buffer_pool_size = 128M
    
    # Remove leading # to turn on a very important data integrity option: logging
    # changes to the binary log between backups.
    # log_bin
    
    # These are commonly set, remove the # and set as required.
    # basedir = .....
    # datadir = .....
    # port = .....
    # server_id = .....
    
    
    # Remove leading # to set options mainly useful for reporting servers.
    # The server defaults are faster for transactions and fast SELECTs.
    # Adjust sizes as needed, experiment to find the optimal values.
    # join_buffer_size = 128M
    # sort_buffer_size = 2M
    # read_rnd_buffer_size = 2M 
    
    # 以下内容手动添加
    [client]
    default-character-set=utf8
    [mysqld]
    port=3306
    server-id=1
    log-bin=mysql-bin
    binlog-do-db=kintech_pd
    sync_binlog=1
    
    basedir=C:ProgramDataMySQLMySQL Server 5.7
    #解压目录下data目录
    datadir=C:ProgramDataMySQLMySQL Server 5.7data
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
    [WinMySQLAdmin]
    C:Program FilesMySQLMySQL Server 5.7inmysqld.exe

    从库 my.ini

    # For advice on how to change settings please see
    # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
    # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
    # *** default location during install, and will be replaced if you
    # *** upgrade to a newer version of MySQL.
    
    [mysqld]
    
    # Remove leading # and set to the amount of RAM for the most important data
    # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
    # innodb_buffer_pool_size = 128M
    
    # Remove leading # to turn on a very important data integrity option: logging
    # changes to the binary log between backups.
    # log_bin
    
    # These are commonly set, remove the # and set as required.
    # basedir = .....
    # datadir = .....
    # port = .....
    # server_id = .....
    
    
    # Remove leading # to set options mainly useful for reporting servers.
    # The server defaults are faster for transactions and fast SELECTs.
    # Adjust sizes as needed, experiment to find the optimal values.
    # join_buffer_size = 128M
    # sort_buffer_size = 2M
    # read_rnd_buffer_size = 2M 
    
    # 以下内容手动添加
    [client]
    default-character-set=utf8
    [mysqld]
    #从库配置
    server_id=2
    #如果库名相同,使用这个
    #replicate-do-db=kintech_pd
    #如果库名不同,使用这个。
    replicate-rewrite-db = kintech_pd -> kps_common
    
    #端口
    port=3306
    character_set_server=utf8
    #解压目录
    basedir=C:ProgramDataMySQLMySQL Server 5.7
    #解压目录下data目录
    datadir=C:ProgramDataMySQLMySQL Server 5.7data
    
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
    [WinMySQLAdmin]
    C:Program FilesMySQLMySQL Server 5.7inmysqld.exe

    主库:记住 File 和 Position

    
    CREATE USER 'slave'@'MySql2服务器ip' IDENTIFIED BY '密码';
    GRANT REPLICATION SLAVE ON *.* TO 'slave'@'MySql2服务器ip';
     
    flush privileges;
    
    show master status;

    从库:

    
    CHANGE MASTER TO 
    master_host = 'MySql1服务器ip',   
    master_user = 'slave',  
    master_password = '密码',  
    master_log_file = 'bin_log.000002',  
    master_log_pos = 631;
    
    start slave;
    
    show slave statusG
    
    

    最后显示:

    代表成功。

  • 相关阅读:
    【洛谷 P5409】 【模板】—第一类斯特林数·列(多项式Ln+多项式快速幂)
    【洛谷 P5395】【模板】—第二类斯特林数·行(NTT)
    【洛谷 P5395】【模板】—第二类斯特林数·行(NTT)
    【洛谷 P5408】【模板】—第一类斯特林数·行(倍增+NTT)
    【洛谷 P5408】【模板】—第一类斯特林数·行(倍增+NTT)
    多测师讲解badboy_录制脚本工具安装001_高级讲师肖sir
    多测师讲解jmetera___启动方式—___高级讲师肖sir
    多测师讲解jmeter的——性能测试理论——高级讲师肖sir
    多测师讲解性能测试 _理论_(总结)高级讲师肖sir
    多测师面试讲解 _第三方测试点_高级讲师肖sir
  • 原文地址:https://www.cnblogs.com/hanjun0612/p/9779704.html
Copyright © 2011-2022 走看看