当前位置:Gxlcms > mysql > 【原创】centos6.4编译安装mysql5.5并为其安装Sphinx引擎支持

【原创】centos6.4编译安装mysql5.5并为其安装Sphinx引擎支持

时间:2021-07-01 10:21:17 帮助过:21人阅读

#mysql5.5改成用cmake安装了,所以先安装cmakecd /data/software/wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gzwget http://www.coreseek.cn/uploads/csft/4.0/coreseek-4.1-beta.tar.gzcd /data/srctar zxf ../software/coreseek-4.1-beta.tar.

#mysql5.5改成用cmake安装了,所以先安装cmake
cd /data/software/
wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
wget http://www.coreseek.cn/uploads/csft/4.0/coreseek-4.1-beta.tar.gz
cd /data/src
tar zxf ../software/coreseek-4.1-beta.tar.gz
tar zxf ../software/cmake-2.8.4.tar.gz
cd cmake-2.8.4
./configure
make && make install
#mysql5.5基本安装
cd /data/src
tar zxf ../software/mysql-5.5.28.tar.gz
cd mysql-5.5.28
cp -r /data/src/coreseek-4.1-beta/csft-4.1/mysqlse storage/sphinx
cmake . -DCMAKE_BUILD_TYPE=Release -DWITH_SPHINX_STORAGE_ENGINE=1
make && make install
#配置
cd /usr/local/mysql
mkdir -p /var/log/mysql /usr/local/mysql/etc
cp support-files/my-medium.cnf /usr/local/mysql/etc/my.cnf
rm -rf /etc/my.cnf
ln -s /usr/local/mysql/etc/my.cnf /etc/my.cnf
vi /etc/my.cnf
##########################################
[mysqld]
basedir         = /usr/local/mysql
datadir         = /usr/local/mysql/data
##########################################
#设置用户组
groupadd -g 88 mysql
adduser -u 88 -g mysql -s /sbin/nologin mysql
#初始化数据库 并将数据库更目录映射到我的熟悉的文件夹/data/database/mysql
./scripts/mysql_install_db --basedir=/usr/local/mysql --user=mysql
chown -R root .
chown -R mysql data
rm -rf /data/database
mkdir -p /data/database
ln -s /usr/local/mysql/data  /data/database/mysql
#更改存放数据库文件权限,这个时候有的文件不存在
chown -R mysql:mysql /data/database/mysql
chmod 770 /data/database/mysql
chmod 770 /data/database/mysql/ib*          
chmod 770 /data/database/mysql/*.err
chmod 770 /data/database/mysql/*.pid
chmod 660 /data/database/mysql/mysql/*
chmod 700 /data/database/mysql/mysql
chmod 700 /data/database/mysql/test
#启动mysql
/usr/local/mysql/bin/mysqld_safe --defaults-extra-file=/usr/local/mysql/etc/my.cnf --user=mysql &
sleep 5
#设置数据库root帐户的密码,并且将密码保存
/usr/local/mysql/bin/mysqladmin -u root password 'XXXXXXXXX'
#如果密码错误,可以先关掉数据库 然后/usr/local/mysql/bin/mysqld_safe --skip-grant-tables &  然后mysql -u root  然后 update user set password=password("XXXXXXXXX") where user='root'; 然后重启数据库
mkdir -p /data/save/
echo 'XXXXXXXXX' > /data/save/mysql_root
#关闭数据库
/usr/local/mysql/bin/mysqladmin -u root -pXXXXXXXXX shutdown
#将数据库的启动|关闭 简洁化
echo '/usr/local/mysql/bin/mysqld_safe --defaults-extra-file=/usr/local/mysql/etc/my.cnf --user=mysql &' > /root/mysql_start
chmod 700 /root/mysql_start
echo '/usr/local/mysql/bin/mysqladmin -u root -p shutdown' > /root/mysql_stop
chmod 700 /root/mysql_stop
#设置数据库开机启动
echo "/root/mysql_start"  >> /etc/rc.d/rc.local
#把mysql的bin文件链接到PATH目录
ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql

#安装sphinx支持!

mysql -uroot -p`cat /data/save/mysql_root`
mysql>install plugin sphinx soname "ha_sphinx.so";
mysql>show engines;

如果一切顺利,将会看到以下信息:
113 【原创】centos6.4编译安装mysql5.5并为其安装Sphinx引擎支持
现在您可以创建sphinx引擎表了:
#创建sphinx引擎表

CREATE TABLE rtindex(
	id bigint( 11 ) NOT NULL ,
	weight integer( 11 ) NOT NULL ,
	title varchar( 255 ) NOT NULL ,
	content varchar( 5000 ) NOT NULL ,
	groupid int( 6 ) NOT NULL ,
	biguid bigint( 11 ) NOT NULL ,
	score float( 6 ) NOT NULL ,
	date_added bigint( 11 ) NOT NULL ,
	author varchar( 255 ) NOT NULL ,
	INDEX ( title )
) ENGINE = SPHINX DEFAULT CHARSET = utf8 CONNECTION = 'sphinx://localhost:9314/rtindex';

完毕。

人气教程排行