安装编译依赖
yuminstallgcc gcc-c++ cmake ncurses-devel bison
安装内存优化jemalloc
wget http://www.canonware.com/download/jemalloc/jemalloc-3.6.0.tar.bz2
tar xjf jemalloc-3.6.0.tar.bz2
cd jemalloc-3.6.0
./configure
make && make install
echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
ldconfig
编译安装
cmake \
-DCMAKE_INSTALL_PREFIX=/data/server/mysql \
-DMYSQL_DATADIR=/data/data/mysql \
-DSYSCONFDIR=/data/server/mysql \
-DMYSQL_UNIX_ADDR=/data/data/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3336 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_DEBUG=0 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1 \
-DENABLE_DOWNLOADS=1 \
-DCMAKE_EXE_LINKER_FLAGS="-ljemalloc" -DWITH_SAFEMALLOC=OFF
make
#多进程编译 编译很消耗系统资源,小内存可能编译通不过
#make -j `grep processor /proc/cpuinfo | wc -l` && make install
make install
初始化MySQL用户、初始化系统表
groupadd mysql
useradd -g mysql mysql -d /home/mysql -s /sbin/nologin
cd /data/server/mysql
chmod a+x ./scripts/mysql_install_db
./scripts/mysql_install_db --user=mysql --basedir=/data/server/mysql --datadir=/data/data/mysql
chown -R mysql:mysql /data/data/mysql
安装为系统服务
cd /data/server/mysql
cp support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on
编辑配置文件/etc/my.cnf
my.cnf 见附件
启动MySQL
#启动
service mysql start
#停止
service mysql stop
#登录
/data/server/mysql/bin/mysql