MySQL5.5编译安装


1、安装依赖

安装编译依赖

yum install gcc 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


2、编译安装

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 install


3、配置

初始化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




4、启动MySQL

 

#启动
service mysql start
#停止
service mysql stop
 
#登录
/data/server/mysql/bin/mysql


你可能感兴趣的:(编译安装,mysql5.5)