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