cszer

cmake安装高版本MySQL(5.5以上版本)

分类: MySQL   标签: ,    评论: 0   阅读:3,212 views

从MySQL5.5 开始就要用cmake安装了,怪不得./configure总提示“没有文件或目录”….
下面是cmake安装MySQL的过程:

1、安装MySQL之前的准备工作

wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.25.tar.gz
groupadd mysql
useradd -r -g mysql mysql
yum install gcc gcc-c++ libtool autoconf automake imake libxml2-devel expat-devel ncurses-devel cmake bison

2、解压源码包

tar -zxvf mysql-5.5.25.tar.gz
cd mysql-5.5.25

3.cmake进行编译

cmake . \
-DCMAKE_INSTALL_PREFIX=/opt/mysql \  #安装到/opt/mysql目录
-DMYSQL_DATADIR=/data0/mysql/ \   #数据存放到/data0/mysql目录
-DMYSQL_UNIX_ADDR=/var/tmp/mysql/mysqld.sock \
-DDEFAULT_CHARSET=utf8 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_SPHINX_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DMYSQL_USER=mysql

make
make install

4、初始化MySQL

cd /opt/mysql
chown -R mysql .
chgrp -R mysql .
scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
cp support-files/my-medium.cnf /etc/my.cnf
bin/mysqld_safe --user=mysql &   #用netstat -tnl查看一下3306端口
cp support-files/mysql.server /etc/init.d/mysqld
cd /usr/local/bin
ln -fs /usr/local/mysql/bin/mysql mysql

5、把MySQL添加系统服务启动

cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
cd /etc/rc.d/init.d
chkconfig --add mysqld
service mysqld start/stop

除非注明,文章皆由( csz )原创,转载请标明本文地址
本文地址: http://www.cszhi.com/20120628/cmake_mysql.html

06-28
2012

发表评论