因为源码包比二进制包安装要复杂一些,特此记录
yum -y install ncurses-devel libaio-devel
rpm -qa ncurses-devel libaio-devel
tar xf cmake-2.8.6.tar.gz -C /usr/src/
cd /usr/src/cmake-2.8.6/
./configure
gmake && gmake install
which cmake
useradd -s /sbin/nologin -M mysql
id mysql
tar xf mysql-5.5.22.tar.gz -C /usr/src/
cd /usr/src/mysql-5.5.22/
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.5.22
-DMYSQL_DATADIR=/usr/local/mysql-5.5.22/data #数据存放目录
-DMYSQL_UNIX_ADDR=/usr/local/mysql-5.5.22/tmp/mysql.sock #MySQL进程间通信的套接字位置
-DDEFAULT_CHARSET=utf8 #默认字符集为utf8
-DDEFAULT_COLLATION=utf8_general_ci #默认字符集排序规则
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii #额外的字符集支持
-DENABLED_LOCAL_INFILE=ON #是否启用加载本地数据
-DWITH_INNOBASE_STORAGE_ENGINE=1 #静态编译innodb存储引擎到数据库
-DWITH_FEDERATED_STORAGE_ENGINE=1 #静态编译FEDERATED存储引擎到数据库
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 #静态编译blackhole存储引擎到数据库
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 #不编译EXAMPLE存储引擎到数据库
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 #不支持数据库分区
-DWITH_FAST_MUTEXES=1
-DWITH_ZLIB=bundled #zlib压缩模式
-DENABLED_LOCAL_INFILE=1 #是否启用本地的LOCAL_INFILE
-DWITH_READLINE=1 #使用捆绑的readline
-DWITH_EMBEDDED_SERVER=1 #是否要建立嵌入式服务器
-DWITH_DEBUG=0 #禁用DEBUG(开启影响性能)
make && make install
ln -s /usr/local/mysql-5.5.22 /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /data
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
ln -s /usr/local/mysql/bin/* /usr/local/bin/
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql(如果这里报错,就指定目录为/usr/local/mysql/data)
/etc/init.d/mysqld start