参考:http://www.cnblogs.com/zhangan/
一、 环境准备
1. 下载软件包
wget http://test.hexin.cn/software/mysql-5.7.9.tar.gz -P /usr/local/src/
wget http://test.hexin.cn/software/cmake-3.4.0.tar.gz -P /usr/local/src/
wget http://test.hexin.cn/software/boost_1_59_0.tar.gz -P /usr/local/src/
2. 安装基础软件
yum -y install make gcc-c bison-devel ncurses-devel
二、 安装配置MySQL
1. 编译安装cmake
tar zxvf /usr/local/src/cmake-3.4.0.tar.gz
cd /usr/local/src/cmake-3.4.0
./configure && make && make install
2. 编译安装boost(编译时不加boost,可以不用安装此软件)
tar zxvf /usr/local/src/boost_1_59_0.tar.gz -C /usr/local/boost/
cd /usr/local/boost/
./bootstrap.sh
./b2
3. 新增用户用户组
groupadd mysql
useradd mysql -g mysql -M -s /sbin/nologin
4. 编译安装MySQL
tar zxvf /usr/local/src/mysql-5.7.9.tar.gz
cd /usr/local/src/mysql-5.7.9/
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
make
make install
三、常用配置参数
● “—prefix” :设定安装路径,默认为“ /usr/local” ;
● “—datadir” :设定MySQL数据文件存放路径;
● “—with-charset” :设定系统的默认字符集;
● “—with-collation” :系统默认的校验规则;
● “—with-extra-charsets” :出了默认字符集之外需要编译安装的字符集;
● “—with-unix-socket-path” :设定socket文件地址;
● “—with-tcp-port” :指定特定监听端口,默认为3306;
● “—with-mysqld-user” :指定运行mysqld的os用户,默认为mysql;
● “—without-query-cache” :禁用Query Cache功能;
● “—without-innodb” :禁用Innodb存储引擎;
● “ --with-partition” :在5.1版本中开启partition支持特性;
● “ --enable-thread-safe-client” :以线程方式编译客户端;
● “—with-pthread” :强制使用pthread 线程库编译;
● “—with-named-thread-libs” :指定使用某个特定的线程库编译;
● “—without-debug” :使用非debug模式;
● “—with-mysqld-ldflags” : mysqld的额外link参数;
● “—with-client-ldflags” : client的额外link参数;