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,没问题。

  • 相关阅读:
    at( ) & [ ]
    正则表达式 & 字符串匹配
    c++ 类 A类调用B类
    c++ 类 类指针&new对象
    重载赋值运算符
    拷贝构造函数 & 拷贝初始化
    链式表达式
    Indirect modification of overloaded element of cmfpaginatorBootstrap has no effect
    chmod(): Operation not permitted
    canvas
  • 原文地址:https://www.cnblogs.com/hankyoon/p/5169697.html
Copyright © 2011-2022 走看看