操作步驟:
1 window 修改my.ini文件。在最底下的
[mysqld]
port=3306
federated
添加federated,支持federated類型的數據引擎。默認是不開啓的。
重啓apache。
打開mysql console執行show engines;可以看到federated是啓用的了。
2 在本地DB中執行以下sql。
CREATE TABLE IF NOT EXISTS `tablename` ( `id` int(11) NOT NULL AUTO_INCREMENT, `appID` int(11) NOT NULL, `issueNo` varchar(100) DEFAULT NULL, `issueTitle` varchar(255) DEFAULT NULL, `issueKicker` varchar(255) DEFAULT NULL, `productID` varchar(255) NOT NULL, `publicationDate` datetime NOT NULL, `price` double NOT NULL, `description` varchar(500) DEFAULT NULL, `status` enum('pending','publishing','published') DEFAULT NULL, `updateTime` datetime NOT NULL, `updateUser` varchar(50) NOT NULL, `bscmsID` int(11) DEFAULT NULL, `filter` varchar(255) DEFAULT NULL, `portraitCoverID` int(11) DEFAULT NULL, `uploadCover` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `status` (`status`), KEY `appID` (`appID`), KEY `publicationDate` (`publicationDate`) ) ENGINE=FEDERATED DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 CONNECTION='mysql://user:[email protected]:3306/dbname/tablename';
注意:密碼不能包含@否則會提示connection string的格式錯誤。
Suggested fix:
Allow the @ character to be escaped, or at least annotate this in the docs (I imagine other chars will also cause a problem, such as / and :. Perhaps the connection string could be specified as: "mysql://'username':'password'@'hostname.tld'/db/table"?
參考:http://bugs.mysql.com/bug.php?id=14810