The Federated storage engine accesses data in a table in a remote database, rather than a local table. When creating a Federated table, the server creates a table definition file in the database directory. No other table is created because the actual data is stored in a remote database. This is different from the storage engine used for the local surface.
1. Check whether the current server configuration supports the Federated storage engine:
Show Engines;
Query results. If the Federated row's Support column value is YES, the current server supports the Federated storage engine.
If the value of the Support column corresponding to the Federated row is NO, we need to configure it. Find the my. ini file in the installation directory of the server, open the file in notepad, add Federated, save, and restart the server.
2. on the remote server, create a local table and import data.
() () () ` () InnoDB CHARSET `departmentweekdata` (`department`, `week`, `interval`, ``) , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , );
3. Create a Federated table on the local server.
() () () ` ;
The CONNECTION string example: CONNECTION = 'mysql: // root: 123@127.0.0.1: 3306/dbTest/testtable ';
4. If you use the MySQL client tool, you can create the Federated Server:
5. If you have created a Federated Server, you can use the following method to create a Federated table:
() () () ` ;
6. After creating the Federated table, you can access the data in the remote database table.