一、环境介绍:
    操作系统:CentOS

    编译工具:cmake-2.8.8.tar

    数据库版本:mysql-5.5.32.tar

二、安装步骤
    2.1 安装CMake工具
    2.1.1 安装C编译器

[root@oldcat_t ~]# yum install gcc –y

    2.1.2 解压并编译安装CMake

[root@oldcat_t tools]# tar xf cmake-2.8.8.tar.gz
[root@oldcat_t tools]# cd cmake-2.8.8
[root@oldcat_t cmake-2.8.8]# ./configure
[root@oldcat_t cmake-2.8.8]# gmake
[root@oldcat_t cmake-2.8.8]# gmake install

    2.1.3 检查CMake安装结果

[root@oldcat_t cmake-2.8.8]# which cmake
/usr/local/bin/cmake

    2.2 安装MySQL
    2.2.1 创建MySQL用户和组

[root@oldcat_t ~]# useradd mysql -s /sbin/nologin -M
[root@oldcat_t ~]# tail -1 /etc/passwd
mysql:x:501:501::/home/mysql:/sbin/nologin

    2.2.2 安装依赖包ncurses-deve

[root@oldcat_t cmake-2.8.8]# yum install ncurses-devel -y

    2.2.3 解压并编译安装MySQL

[root@oldcat_t tools]# tar xf mysql-5.5.32.tar.gz 
[root@oldcat_t tools]# cd mysql-5.5.32
[root@oldcat_t tools]# cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \
-DMYSQL_DATADIR=/application/mysql-5.5.32/data/ \
-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0
[root@oldcat_t mysql-5.5.32]# make
[root@oldcat_t mysql-5.5.32]# make install
注意:如果在网页上直接复制以上参数,可能会自动在-DWITH之间增加空格,必须手工去除空格才会正常执行!

    2.3.4 配置软链接

[root@oldcat_t mysql-5.5.32]# ln -s /application/mysql-5.5.32/ /application/mysql

    2.3 配置mysql数据库
    2.3.1 将MySQL的数据文件目录授权给mysql用户

[root@oldcat_t ~]# chown -R mysql.mysql /application/mysql/data/
[root@oldcat_t ~]# chmod -R 1777 /tmp

    2.3.2 拷贝配置文件到etc目录下

[root@oldcat_t ~]# cp /application/mysql/support-files/my-small.cnf /etc/my.cnf

    2.3.3 拷贝启动文件到/etc/init.d/目录下并授权给MySQL用户

[root@oldcat_t ~]# cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@oldcat_t ~]# chown mysql.mysql /etc/init.d/mysqld
[root@oldcat_t ~]# ll /etc/init.d/mysqld 
-rwxr-xr-x. 1 mysql mysql 10934 12月  1 08:12 /etc/init.d/mysqld

    2.3.4 初始化MySQL数据库

[root@oldcat_t ~]# cd /application/mysql/scripts/
[root@oldcat_t scripts]# ls
mysql_install_db
[root@oldcat_t scripts]# ./mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK
......此处省略

    2.3.5 配置全局环境变量

[root@oldcat_t scripts]# echo "export PATH=/application/mysql/bin:$PATH" >> /etc/profile
[root@oldcat_t scripts]# . /etc/profile
[root@oldcat_t scripts]# tail -1 /etc/profile
export PATH=/application/mysql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

    2.3.6 启动MySQL数据库

[root@oldcat_t ~]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS!  
[root@oldcat_t ~]# netstat -lntup|grep 330*
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      23166/mysqld
[root@oldcat_t ~]# lsof -i :3306
COMMAND   PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mysqld  23166 mysql   10u  IPv4  79990      0t0  TCP *:mysql (LISTEN)

    2.3.7 登录MySQL数据库

[root@oldcat_t ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 32
Server version: 5.5.32 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)