sqlcft/lib/mysql/plugin/
②、64位Linux操作系统:
wget http://mysqlcft.googlecode.com/files/mysqlcft-1.0.0-x86_64-bin.tar.gz
tar zxvf mysqlcft-1.0.0-x86_64-bin.tar.gz
mkdir -p /usr/local/mysqlcft/lib/mysql/plugin/
cp mysqlcft.so /usr/local/mysqlcft/lib/mysql/plugin/
4、安装mysqlcft.so插件
①、从命令行登入MySQL服务器:
/usr/local/mysqlcft/bin/mysql -u root -p -S /mysql/3306/mysql.sock
②、安装mysqlcft.so插件的SQL语句:
INSTALL PLUGIN mysqlcft SONAME ''mysqlcft.so'';
③、查看mysqlcft.so插件是否安装成功的SQL语句:
SELECT * FROM mysql.plugin;
SHOW PLUGINS;
附:如果要卸载mysqlcft.so插件,执行以下SQL语句(如果已经创建了mysqlcft索引,请先删除mysqlcft索引,再卸载mysqlcft.so插件):
UNINSTALL PLUGIN mysqlcft;
五、为已经存在的表添加mysqlcft中文全文索引
1、创建单列全文索引SQL语句
ALTER IGNORE TABLE 数据库名.表名 ADD FULLTEXT INDEX 全文索引名 (字段名) WITH PARSER mysqlcft;
2、创建全文联合索引SQL语句
ALTER IGNORE TABLE 数据库名.表名 ADD FULLTEXT INDEX 全文联合索引名 (字段名1,字段名2) WITH PARSER mysqlcft;
六、重建mysqlcft中文全文索引(索引损坏时需要用到)
REPAIR TABLE 数据库名.表名 QUICK;
七、建表时创建mysqlcft中文全文索引+全文搜索测试
1、以latin1字符集为例
CREATE DATABASE `mysqlcft_latin1` DEFAULT CHARACTER SET latin1;
USE `mysqlcft_latin1`;
CREATE TABLE `test` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(200) DEFAULT NULL,
`body` mediumtext,
PRIMARY KEY (`id`),
FULLTEXT KEY `title_body` (`title`,`body`) WITH PARSER mysqlcft
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `mysqlcft_latin1`.`test` (`id`, `title`, `body`) VALUES (NULL, ''北京房价'', ''北京市统计局、国家统计局北京调查总队近日联合对外发布消息,今年以来,北京的商品房价格一直呈上升趋势,五环路以内住宅期房均价已涨至13754元/平方米。'');
INSERT INTO `mysqlcft_latin1`.`test` (`id`, `title`, `body`) VALUES (NULL, ''北京中心城区今起可无线宽带上网 奥运期间免费'', ''新浪科技讯 6月25日消息,北京无线城市一期网络今日起试运行,即日起北京市民和海外游客可以通过无线网络在北京中心城区接入互联网。'');
INSERT INTO `mysqlcft_latin1`.`test` (`id`, `title`, `body`) VALUES (NULL, ''数据库'', ''欢迎使用MySQL中文全文索引插件mysqlcft!'');
SELECT * FROM mysqlcft_latin1.test WHERE MATCH(title,body) AGAINST (''13754元/平方米'' IN BOOLEAN MODE);
SELECT * FROM mysqlcft_latin1.test WHERE MATCH(title,body) AGAINST (''6月25日'' IN BOOLEAN MODE);
SELECT * FROM mysqlcft_latin1.test WHERE MATCH(title,body) AGAINST (''北京'' IN BOOLEAN MODE);
SELECT * FROM mysqlcft_latin1.test WHERE MATCH(title,body) AGAINST (''北京 宽带'' IN BOOLEAN MODE);
SELECT * FROM mysqlcft_latin1.test WHERE MATCH(title,body) AGAINST (''mysqlcft'' IN BOOLEAN MODE);
SELECT * FROM mysqlcft_latin1.test WHERE MATCH(title,body) AGAINST (''数据'' IN BOOLEAN MODE);
2、以UTF-8字符集为例
CREATE DATABASE `mysqlcft_utf8` CHARACTER SET utf8;
USE `mysqlcft_utf8`;
CREATE TABLE `test` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(200) DEFAULT NULL,
`body` mediumtext,
PRIMARY KEY (`id`),
FULLTEXT KEY `title_bod