• MySQL 5.6数据库配置主从同步


    win7环境下mysql主从搭建

    我下载的是压缩包,免安装的那种

    1、简单安装

    解压后把my-default.ini复制一份改为my.ini默认mysql会找这个文件,首先从system32下找,然后在安装目录找

    basedir = D:/soft_install/Java/mysql_slave_one
    datadir = D:/soft_install/Java/mysql_slave_one/data
    port = 3307
    server_id = 2

    只需要配置这几个东西就可以了

    然后将mysql安装成服务

    mysqld.exe --install MySql_master--defaults-file=D:/soft_install/Java/mysql_slave/my.ini

    就可以将mysql安装成服务

    2、主服务器配置

    log_bin = mysql_bin
    binlog_format = ROW
    binlog_cache_size = 4M
    max_binlog_size = 1G
    max_binlog_cache_size = 128M
    binlog-do-db = test
    binlog-ignore-db=mysql
    skip-log-warnings=yes
    expire_logs_days=1

    # These are commonly set, remove the # and set as required.
    basedir = D:/soft_install/Java/mysql_master
    datadir = D:/soft_install/Java/mysql_master/data
    port = 3306
    server_id = 1

    进入服务器,授权同步用户

    GRANT REPLICATION SLAVE ON *.* TO'test_user'@'127.0.0.1'   identified by '123456';

    3、从服务器配置

    log_bin=mysql_bin
    relay-log=relay_log
    replicate-ignore-db=mysql 
    replicate-do-db=test

    # These are commonly set, remove the # and set as required.
    basedir = D:/soft_install/Java/mysql_slave_one
    datadir = D:/soft_install/Java/mysql_slave_one/data
    port = 3307
    server_id = 2

    4、启动时先启动主服务器,然后启动从服务器

    进入从服务器,运行以下命令

    change master tomaster_host='127.0.0.1',master_user='test_user',master_password='123456',
     master_log_file='mysql-bin.000015',master_log_pos=120;

    start slave

    其中的 'mysql-bin.000015',120 是需要进如主服务器运行 show masterstatus来查看才能知道的 
  • 相关阅读:
    form提交上传图片
    存储过程分页
    表格隔行换色效果
    C#获取本地局域网IP
    sql 拆分字符串并循环取值
    sql日期转换
    HDU 4858
    HDU 1199
    URAL 1306
    Codeforces Round #288 (Div. 2)
  • 原文地址:https://www.cnblogs.com/wujiachen260727/p/4500100.html
Copyright © 2020-2023  润新知