安装前我们先安装一些准备软件,不然cmake会报错
#yum install ncurses-devel
#yum install bison
#yum install -y bison ncurses ncurses-devel gcc gcc-c++ make unzip openssl openssl-devel cmake
安装cmake:
tar zxvf cmake-2.8.4.tar.gz
cd cmake-2.8.4
./configure --prefix=/usr/local/cmake
make && make install
ln -s /usr/local/cmake/bin/cmake /sbin/
安装mysql5.5.20
groupadd mysql //所以在这里我们要建一个msyql的用户和组
useradd -g mysql mysql -s /usr/sbin/nologin
usermod -a -G mysql mysql // 如果有mysql账户
mkdir /usr/local/mysql //创建目录
mkdir /usr/local/mysql/data
mkdir /usr/local/mysql/log
进入mysql-5.5.20的解压目录:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data
make && make install
chown -R mysql:mysql /usr/local/mysql //更改权限
vi /etc/my.cnf //加上以下内容
[mysqld]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
log-error = /usr/local/mysql/log/mysql_error.log
pid-file = /usr/local/mysql/mysql.pid
user = mysql
tmpdir = /tmp
进入mysql的安装目录/usr/local/mysql下:
#scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --defaults-file=/etc/my.cnf --user=mysql //初始化mysql数据库
启动mysql : /usr/local/mysql/bin/mysqld_safe --user=mysql & 或使用下列命令把mysql添加为系统服务。
#cd /usr/local/mysql/support-files/
#cp ./mysql.server /etc/init.d/mysqld
#/etc/init.d/mysqld start
加入开机启动:
ln -s /usr/local/mysql/bin/* /usr/bin/
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18