I used SQL Server databases all the time. Recently, my company has a new project to use MySQL databases, many of which are cross-server access. SQL Server uses linked servers for cross-server access, while MySQL is implemented through the federated engine.
To configure the federated engine, MySQL or later is required. The specific configuration method is as follows:
1. Check whether the federated engine is installed.
Enter the command: Show engines;
The result is as follows:
Engine Support comment transactions XA savepoints
Memory Yes hash based, stored in memory, useful for temporary tables no
Federated no federated MySQL storage engine
MyISAM Yes default engine as of MySQL 3.23 With great performance no
Blackhole Yes/dev/null storage engine (anything you write to it disappears) No
Mrg_myisam Yes collection of identical MyISAM tables no
CSV Yes CSV storage engine no
Archive Yes archive storage engine no
InnoDB default supports transactions, row-level locking, and foreign keys yes
The federated engine is not enabled.
2. Enable the federated Engine
In Windows, add federated to my. ini to enable Federated;
In Linux, you must add the option during compilation and then add federated to my. ini to enable this function.
3. Create a remote data table Link
Assume that there is a database dbtesta on servera and database dbtestb on serverb. You need to create the table tabletesta link to remote_tabletesta on the database dbtesta of servera on the database dbtestb of serverb, the statement is as follows:
Create Table remote_tabletesta... engine = federated connection = 'mysql: // root: 123123 @ servera: 3306/dbtesta/tabletesta ';
4. Use the remote data table Link
In the preceding example, the table remote_tabletesta is operated directly on the database dbtestb of serverb, that is, the table tabletesta of the database dbtesta on servera.