zoukankan      html  css  js  c++  java
  • MySQL不同库名相同表结构实现主从配置

    数据库版本 5.6.16

    在两个服务器上,存在不同名字的数据库,但是两个数据库中的所有表结构相同,实现主从复制。

    主库服务器的数据库名为yoon,从库服务器的库名为hank

    在从库的my.cnf配置文件中添加如下参数,并重启数据库
    replicate-rewrite-db = yoon -> hank

    设置主从:
    change master to master_host='172.16.9.243',master_port=3306,master_user='master',master_password='123456',master_log_file='mysql-bin.000036',master_log_pos=107;

    在主库插入数据
    mysql> insert into yoon values (1,'a');
    Query OK, 1 row affected (0.00 sec)


    mysql> select * from yoon;
    +------+------+
    | id   | name |
    +------+------+
    |    1 | a    |
    +------+------+
    1 row in set (0.00 sec)


    在从库查看:
    mysql> use hank
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A


    Database changed
    mysql> select * from yoon;
    +------+------+
    | id   | name |
    +------+------+
    |    1 | a    |
    +------+------+
    1 row in set (0.00 sec)


    OK,没问题。

  • 相关阅读:
    windows下命令行
    利用border画三角形
    正则
    flex布局
    css笔记
    W3C标准
    SEO相关
    左边固定,右边自适应(解决方案)
    容错性测试的测试点
    Charles安装及使用教程
  • 原文地址:https://www.cnblogs.com/hankyoon/p/5169697.html
Copyright © 2011-2022 走看看