So you can user FEDERATED Storage Engine, which allows you to declare tables as a link to another table on another server.
The FEDERATED storage engine allows MySQL users to access tables on a remote MySQL
database without using replication or cluster technology.
FEDERATED table automatically pulls the data from the remote tables.
No data is stored on the local tables.
How to use Federated Engine?
Step1: Enable Federated Engine.
SHOW ENGINES;
Step2: edit /etc/my.cnf and in the [mysqld] section, add the line:
federated
Restart Mysql Service...
Step3: create a standard table on a remote MySQL server
CREATE TABLE RemoteTable(
id INT(20) NOT NULL AUTO_INCREMENT,
name VARCHAR(32) NOT NULL DEFAULT '',
Place varchar(200) NOT NULL DEFAULT '',
PRIMARY KEY (id)
);
Step4: FEDERATED table is created on the local MySQL serverCREATE TABLE federated_table (
id INT(20) NOT NULL AUTO_INCREMENT,
name VARCHAR(32) NOT NULL DEFAULT '',
Place varchar(200) NOT NULL DEFAULT '',
PRIMARY KEY (id)
)
ENGINE=FEDERATED
DEFAULT CHARSET=latin1
CONNECTION='mysql://root:1234@192.168.1.1:3306/AccountsReportdb/RemoteTable';
Now when you execute a query on federated_table, you will get the data from RemoteTableResult:
Remote Server:
Local Server:
CONNECTION='mysql://username:password@hostname:port/database/tablename'
CONNECTION='mysql://username@hostname/database/tablename'
CONNECTION='mysql://username:password@hostname/database/tablename'
Youtube Link:
0 Comments