zoukankan      html  css  js  c++  java
  • mysql 主从数据库设置方法

    1.主从数据库都需开启bin-log日志

    2.在my.ini(windows)或my.cnf(linux)配置文件中添加 server-id = 1(主从配置 id 必须不同)

    例子:
    
    [mysqld]
    
    log-bin=D:/phpStudy/MySQL/log/mysql-bin.log
    server-id = 1

    3.授权从服务器连接主服务器(用于获取bin-log)

    例子:
    
    授权给从数据库服务器192.168.10.131
    mysql> GRANT REPLICATION SLAVE ON *.* to 'name'@'192.168.10.131' identified by 'password';

    4.从服务器配置:

    例子:
    
    执行同步SQL语句
    mysql> change master to
    
    master_host='192.168.10.131',
    master_user='name',
    master_password='password',
    master_log_file='mysql-bin.000001',
    master_log_pos=107;
    
    正确执行后启动Slave同步进程
    mysql> start slave;
    
    主从同步检查
    mysql> show slave statusG
    如果:
    Slave_IO_Running: Yes Slave_SQL_Running: Yes
    说明配置成功!

    注:其中master_log_file,master_log_pos的值在主数据库用

    mysql>show master status;
  • 相关阅读:
    Hello World
    函数
    js基础
    html
    npm
    数据库
    前端了解的简要php
    模块
    scrapy爬虫
    php升级代码检查
  • 原文地址:https://www.cnblogs.com/zjhblogs/p/5584434.html
Copyright © 2011-2022 走看看