MySQL different library name same table structure implement master-slave configuration

Source: Internet
Author: User

Database version 5.6.16

On two servers, there is a database with different names, but all the tables in two databases have the same structure, implementing master-slave replication.

The database name for the primary library server is Yoon, and the library name is Hank from the library server

In the MY.CNF configuration file from the library, add the following parameters and restart the database
Replicate-rewrite-db = Hank Yoon

Set master/Slave:
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;

Inserting data in the main library
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)


In view from library:
Mysql> use Hank
Reading table information for completion of table and column names
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, no problem.

MySQL different library name same table structure implement master-slave configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.