本节主要内容:
centos6.4编译安装mysql5.5及Sphinx引擎。
1,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
2,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
3,配置mysql
复制代码 代码示例:
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]
ba
sedir = /usr/local/mysql
datadir = /usr/local/mysql/data
4,设置用户组
复制代码 代码示例:
groupadd -g 88 mysql
adduser -u 88 -g mysql -s /sbin/nologin mysql
5,初始化数据库 并将数据库更目录映射到我的熟悉的文件夹/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
6,更改存放数据库文件权限,这个时候有的文件不存在
复制代码 代码示例:
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
7,启动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;
如果一切顺利,将会看到以下信息:
8,创建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';
至此,centos6.4编译安装mysql5.5及Sphinx引擎的工作顺利完成。