1. Check to see if the federated engine is turned on
Click to enter Navicat and click on the keyboard F6, the command line interface, input instructions: show engines;
2. Turn on the Federated engine
Windows systems: adding federated to My.ini
3. Create a mapping table
There is a MySQL database test_a on Server A and a MySQL database test_b on server B. Now you need to map the user table data in the TEST_A library to the database Test_b. The table user needs to be established in the database Test_b, with the engine and CONNECTION in mind .
CREATE TABLE User(IDint( One) not NULL, namevarchar( -) not NULL, Ageint( One) not NULL, PRIMARY KEY(ID)) ENGINE=Federated CONNECTION='Mysql://test:[email Protected]:3306/test_a/user'DEFAULTCHARSET=UTF8;
In the link above, test is the user name of the linked database; 123456 is the password; 192.168.1.5 is the database server ip;3306 is the database server port; test_a is the database name; user is the database table name.
Here are some examples of connection strings:
CONNECTION = ' Mysql://username:[email protected]:p ort/database/tablename ' CONNECTION = ' Mysql://[email Protected]/database/tablename ' CONNECTION = ' Mysql://username:[email Protected]/database/tablename '
4. The MySQL database test_a settings on Server A can be accessed remotely, and the test user is assigned Read and write access to the related table.
5. At this point, after modifying the user table in the Test_b, you can see the changes in the user table in the test_a, in the same vein, after modifying the user table in Test_a, you can test_ You see the changes in the user table in B.
MySQL Open federated Engine implements database table mapping