编译版本分别为:mysql-5.1.70,mysql-5.5.15
1、mysql-5.1.70 编译
依赖包:
libtermcap
libtermcap-devel
imake
autoconf
automake
libtool
m4
libstdc++-devel
gcc-c++
zlib-devel
编译安装MySQL5.1.70
[root@test4 ~]# yum install libtermcap libtermcap-devel imake autoconf automake libtool m4
libstdc++-devel gcc-c++ zlib-devel ncurses-devel
[root@test4 ~]# useradd -M -s /sbin/nologin mysql
[root@test4 ~]# mkdir /usr/local/mysql
[root@test4 ~]# mkdir /mysql/data -p
[root@test4 ~]# tar zxvf mysql-5.1.70.tar.gz
[root@test4 mysql-5.1.70]# ./configure --prefix=/usr/local/mysql \ mysql的安装目录
--datadir=/mysql/data \
--enable-assembler \
--with-client-ldflags=-all-static\
--with-unix-socket-path=/tmp \
--with-charset=utf8 \
--enable-thread-safe-client \
--with-pthread\
--without-debug \
--with-big-tables \
--enable-community-features\
--enable-profiling \
--enable-local-infile \
--with-fast-mutexes\
--with-plugins=partition,federated,ndbcluster,innobase,csv,blackhole,myisam,innodb_plugin
[root@test4 mysql-5.1.70]# make
[root@test4 mysql-5.1.70]# strip sql/mysqld
[root@test4 mysql-5.1.70]# make install
[root@test4 mysql-5.1.70]# cp support-files/my-medium.cnf /etc/my.cnf
#/etc/my.cnf 文件中的参数据实际情况而定
[root@test4 mysql-5.1.70]# cp support-files/mysql.server /etc/init.d/mysqld
#修改/etc/init.d/mysqld文件中的"datadir"参数值为/mysql/data(datadir=/mysql/data)
[root@test4 mysql-5.1.70]# chmod u+x /etc/init.d/mysqld
[root@test4 mysql-5.1.70]# chkconfig --add mysqld(chkconfig中无此项服务时执行)
[root@test4 mysql-5.1.70]# /usr/local/mysql/bin/mysql_install_db --user=mysql --datadir= /mysql/data
[root@test4 mysql-5.1.70]# chown -R mysql.mysql /data/mysql/
[root@test4 mysql-5.1.70]# service
mysqld start
[root@test4 mysql-5.1.70]# /usr/local/mysql/bin/mysqladmin -u root password '123456'
[root@test4 mysql-5.1.70]# echo "PATH=\"/usr/local/mysql/bin:/data/bin/:\$PATH\"">> /etc/profile
[root@test4 mysql-5.1.70]# exportPATH="/usr/local/mysql/bin:/data/bin/:$PATH"
2、mysql-5.5.15编译
OS架构:x86_32
MySQL版本:mysql-5.5.15
Linux版本:Linux 2.6.18-194.el5
依赖包
libtermcap
libtermcap-deve
imake
autoconf
automake
libtool
m4
libstdc++-devel
gcc-c++
zlib-devel
ncurses-devel
bison
[root@localhost ~]#
mysql-5.5.15 安装需要 cmake (从5.5.7开始引入)的支持,请先至 cmake官网下cmake。链接地址如下:
http://www.cmake.org/cmake/resources/software.html
[root@localhost sourse]# ll
-rw-r--r-- 1 root root
5517977 Sep 14 14:45cmake-2.8.5.tar.gz
-rw-r--r-- 1 root root 23774015 Sep 14 12:33mysql-5.5.15.tar.gz
[root@localhost sourse]#
1> cmake安装
[root@localhost sourse]#
tar-xzvf
cmake-2.8.5.tar.gz
[root@localhost cmake-2.8.5]# vi
README
从此文档中查看cmake的安装步骤,如下:
(1)
[root@localhost cmake-2.8.5]#./bootstrap
(2)
[root@localhost cmake-2.8.5]# gmake
(3)
[root@localhost cmake-2.8.5]# makeinstall
可通过运行 [root@localhost cmake-2.8.5]#
ccmake命令查看cmake使用说明。
可参考如下网址深入了解make与cmake的使用方式:
http://forge.mysql.com/wiki/Autotools_to_CMake_Transition_Guide
2> mysql-5.5.15安装
A、建立mysql用户及组
[root@localhost cmake-2.8.5]# useradd
mysql
[root@localhost cmake-2.8.5]# id mysql
uid=502(mysql) gid=502(mysql) groups=502(mysql)
B、解压mysql并开始安装
[root@localhost sourse]# tar -xzvfmysql-5.5.15.tar.gz
[root@localhost mysql-5.5.15]# cmake-DCMAKE_INSTALL_PREFIX=/var/local/mysql \
-DMYSQL_DATADIR=/var/local/mysql/data/\
-DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DMYSQL_UNIX_ADDR=/var/local/mysql/mysqld.sock\
-DMYSQL_TCP_PORT=3306-DENABLED_LOCAL_INFILE=1 \
-DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8\
-DDEFAULT_COLLATION=utf8_general_ci-DMYSQL_USER=mysql
相关参数的查询请参考帮助文档,如:
(1)[root@localhost mysql-5.5.15]#
mancmake
(2)[root@localhost mysql-5.5.15]# cmake . -LH
(3)查看官方文档
http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html
继续mysql安装
[root@localhost mysql-5.5.15]#
make
[root@localhost mysql-5.5.15]#
makeinstall
到此,mysql的后续安装同 上面的 mysql-5.1.50,只是 初始化 数据文件脚本 mysql_install_db在 mysql-5.5.15时,换了个目录,如下:
[root@localhost mysql-5.5.15]#/var/local/mysql/scripts/mysql_install_db--basedir=/var/local/mysql --datadir=/var/local/mysql/data--user=mysql