4-06 7 views
一、环境
DB Instance 1:
1 2 |
IP: 54.250.120.111 LAN: 10.132.29.84 |
创建fross用户,并设置密码(xxxxxxx)
1 2 |
[root@ip-10-132-29-84 ~]# useradd fross [root@ip-10-132-29-84 ~]# passwd fross |
设定系统语言
1 2 |
[root@ip-10-132-29-84 ~]# vim /etc/sysconfig/i18n LANG="en_US.UTF-8" |
设置时区
1 |
[root@ip-10-132-30-241 ~]# ln -sf /usr/share/zoneinfo/Japan /etc/localtime |
二、安装全文检索库
2.1 安装相关依赖
1 2 3 |
[root@ip-10-132-29-84 soft]# yum localinstall http://packages.groonga.org/centos/6/x86_64/Packages/mecab-0.996-1.el6.x86_64.rpm [root@ip-10-132-29-84 soft]# yum localinstall http://packages.groonga.org/centos/6/x86_64/Packages/mecab-devel-0.996-1.el6.x86_64.rpm [root@ip-10-132-29-84 soft]# yum localinstall http://packages.groonga.org/centos/6/x86_64/Packages/mecab-ipadic-2.7.0.20070801-6.el6.1.x86_64.rpm |
三、安装MySQL5.5
3.1 安装
1 2 3 |
[root@ip-10-132-29-84 ~]# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm [root@ip-10-132-29-84 ~]# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm [root@ip-10-132-29-84 ~]# yum --enablerepo=remi install mysql mysql-server -y |
3.2 设置开机启动,并启动MySQL
1 2 |
[root@ip-10-132-29-84 ~]# chkconfig mysqld on [root@ip-10-132-29-84 ~]# service mysqld start |
3.3 设置密码
1 2 |
[root@ip-10-132-29-84 ~]# mysqladmin -u root password 'XXXXXX' [root@ip-10-132-29-84 ~]# mysql -u root -pXXXXXX |
3.4 允许root远程登录访问frossDB
1 2 3 4 5 |
[root@ip-10-132-29-84 ~]# mysql -u root -pXXXXXX mysql> CREATE USER root@'54.250.120.111' IDENTIFIED BY 'XXXXXX'; mysql> CREATE USER root@'10.132.30.241' IDENTIFIED BY 'XXXXXX'; mysql> GRANT ALL PRIVILEGES ON fross.* TO root; mysql> flush privileges; |
3.5 Web1 访问测试
1 |
[fross@ip-10-132-30-241 shell]$ mysql -u root -pXXXXXX -h 10.132.29.84 fross |
3.6 MySQL安全设定
1 |
[root@ip-10-132-29-84 ~]# mysql_secure_installation |
四、安装MySQL-Mecab插件(mysqlftppc-mecab)
4.1 下载mysql的mecab插件
4.1 下载mysql的mecab插件
1 |
[root@ip-10-132-29-84 soft]# git clone https://github.com/y-ken/mysqlftppc-mecab.git |
4.2 编译安装
1 2 3 4 5 6 7 8 9 |
[root@ip-10-132-29-84 soft]# cd mysqlftppc-mecab [root@ip-10-132-29-84 mysqlftppc-mecab]# aclocal [root@ip-10-132-29-84 mysqlftppc-mecab]# libtoolize --automake [root@ip-10-132-29-84 mysqlftppc-mecab]# automake --add-missing [root@ip-10-132-29-84 mysqlftppc-mecab]# automake [root@ip-10-132-29-84 mysqlftppc-mecab]# autoconf [root@ip-10-132-29-84 mysqlftppc-mecab]# ./configure --with-mysql-config=/usr/bin/mysql_config --with-mecab-cofnig=/usr/local/bin/mecab-config --with-icu-config=/usr/local/bin/icu-config [root@ip-10-132-29-84 mysqlftppc-mecab]# make [root@ip-10-132-29-84 mysqlftppc-mecab]# make install |
4.3 导入插件到MySQL
1 2 |
[root@ip-10-132-29-84 mysqlftppc-mecab]# mysql -u root -pXXXXXXX mysql> install plugin mecab soname 'libftmecab.so'; |
4.4 修改MySQL配置
1 2 3 4 5 6 7 8 9 10 |
[root@ip-10-132-29-84 mysqlftppc-mecab]# vi /etc/my.cnf character_set_server=utf8 lower_case_table_names = 1 skip-character-set-client-handshake # mysqlftppc mecab_normalization = KC mecab_unicode_version = 3.2 mecab_dicdir = /usr/lib64/mecab/dic/ipadic ft_min_word_len=2 |
4.5 重启MySQL服务
1 |
[root@ip-10-132-29-84 mysqlftppc-mecab]# service mysqld restart |
五、测试
5.1 创建库
1 2 |
[root@ip-10-132-29-84 mysqlftppc-mecab]# mysql -u root -pxxxxxx mysql> create database test; |
5.2 创建表
1 2 |
mysql> use test; mysql> CREATE TABLE ft_mecab (c TEXT, FULLTEXT(c) WITH PARSER mecab) ENGINE=MyISAM DEFAULT CHARSET=utf8; |
5.3 插入数据
1 |
mysql> INSERT INTO ft_mecab VALUES("今日の天気は晴れです。"); |
5.4 查询
1 2 3 4 5 6 7 |
mysql> SELECT * FROM ft_mecab WHERE MATCH(c) AGAINST('+"今日の天気"' IN BOOLEAN MODE); +-----------------------------------+ | c | +-----------------------------------+ | 今日の天気は晴れです。 | +-----------------------------------+ 1 row in set (0.00 sec) |
如果想赏钱,可以用微信扫描下面的二维码,一来能刺激我写博客的欲望,二来好维护云主机的费用; 另外再次标注博客原地址 itnotebooks.com 感谢!