Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选

首页 / 数据库 / MySQL / MySQL 5.5 编译详解

说明:蓝色=命令名称      浅绿=命令参数      浅蓝=选项      紫色=目录      系统环境:CentOS  5.7  x86_64一、安装简介用户名:mysql
安装目录:/usr/local/mysql-5.5.20
数据库目录:/data/mysql/data
源码包:mysql-5.5.21.tar.gz自动部署脚本可在 http://www.linuxidc.com/Linux/2012-06/63670.htm 下载二、安装准备添加用户
useradd -s /sbin/nologin mysql建立所需目录
mkdir -p /data/mysql/data
chown -R mysql:mysql /data/mysql安装编译所需文件或程序
yum install gcc gcc-c++ cmake  ncurses-devel bison下载源码包
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.21.tar.gz/from/http://mirror.services.wisc.edu/mysql/  -P /usr/local/src三、编译安装cd /usr/local/src
tar xvf mysql-5.5.21.tar.gz
cd mysql-5.5.21CFLAGS="-O3" CXX=gcc
CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti"
cmake -DMYSQL_USER=mysql
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.5.21
-DMYSQL_DATADIR=/data/mysql/data
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock
-DEXTRA_CHARSETS=all
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DENABLED_LOCAL_INFILE=1
-DWITH_EMBEDDED_SERVER=1 
-DWITH_DEBUG=0
注:详细参数见下文补充内容。make -j 2 && make install
注:-j 用来指定CPU核心数,可加快编译速度,不加也可以。chown -R mysql:mysql /usr/local/mysql-5.5.21/mv /usr/local/src/mysql-5.5.21/support-files/my-large.cnf /etc/my.cnf
注:在/usr/local/src/mysql-5.5.21/support-files/文件夹中有多个my-****.cnf 配置文件,具体用那一个配置文件根据自己实际情况。可以通过查看配置文件的头部信息来了解配置问价适合的配置。例如
[root@localhost support-files]# head /usr/local/src/mysql-5.5.21/support-files/my-huge.cnf
# Example MySQL config file for very large systems.
#
# This is for a large system with memory of 1G-2G where the system runs mainly
# MySQL.mv /usr/local/src/mysql-5.5.21/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --level 345 mysqld on/usr/local/mysql-5.5.21/scripts/mysql_install_db --user=mysql
--defaults-file=/etc/my.cnf
--basedir=/usr/local/mysql-5.5.21/
--datadir=/data/mysql/data/ echo "export PATH=/usr/local/mysql-5.5.21/bin:$PATH" >>/etc/profile
source /etc/profile
   
补充:
从mysql5.5起,mysql源码安装开始使用cmake。下面是 mysql 5.5 与以前的参数对照:
configure CommandCMake Command
./configurecmake .
./configure --helpcmake . -LH or ccmake .
Parameterconfigure OptionCMake OptionCMake Notes
Installation base directory--prefix=/usr-DCMAKE_INSTALL_PREFIX=/usr
 
mysqld directory--libexecdir=/usr/sbin-DINSTALL_SBINDIR=sbininterpreted relative to prefix
Data directory--localstatedir=/var/lib/mysql-DMYSQL_DATADIR=/var/lib/mysql
 
Config directory (for my.cnf)--sysconfdir=/etc/mysql-DSYSCONFDIR=/etc/mysql
 
Plugin directory--with-plugindir=/usr/lib64/mysql/plugin-DINSTALL_PLUGINDIR=lib64/mysql/plugininterpreted relative to prefix
Man page directory--mandir=/usr/share/man-DINSTALL_MANDIR=share/maninterpreted relative to prefix
Shared-data directory--sharedstatedir=/usr/share/mysql-DINSTALL_SHAREDIR=sharethis is where aclocal/mysql.m4 should be installed
Library installation directory--libdir=/usr/lib64/mysql-DINSTALL_LIBDIR=lib64/mysqlinterpreted relative to prefix
Header installation directory--includedir=/usr/include/mysql-DINSTALL_INCLUDEDIR=include/mysqlinterpreted relative to prefix
Info doc directory--infodir=/usr/share/info-DINSTALL_INFODIR=share/infointerpreted relative to prefix
Parameterconfigure OptionCMake OptionCMake Notes
readline library--with-readline-DWITH_READLINE=1
 
SSL library--with-ssl=/usr-DWITH_SSL=system
 
zlib library--with-zlib-dir=/usr-DWITH_ZLIB=system
 
libwrap library--without-libwrap-DWITH_LIBWRAP=0
 
Parameterconfigure OptionCMake OptionCMake Notes
TCP/IP port number--with-tcp-port-=3306-DMYSQL_TCP_PORT=3306
 
UNIX socket file--with-unix-socket-path=/tmp/mysqld.sock-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock
 
Enable LOCAL for LOAD DATA--enable-local-infile-DENABLED_LOCAL_INFILE=1
 
Extra charsets--with-extra-charsets=all-DEXTRA_CHARSETS=alldefault is "all"
Default charset--with-charset=utf8-DDEFAULT_CHARSET=utf8
 
Default collation--with-collation=utf8_general_ci-DDEFAULT_COLLATION=utf8_general_ci
 
Build the server--with-servernone
 
Build the embedded server--with-embedded-server-DWITH_EMBEDDED_SERVER=1
 
libmysqld privilege control--with-embedded-privilege-controlnonealways enabled?
Install the documentation--without-docsnone
 
Big tables--with-big-tables, --without-big-tablesnonetables are big by default
mysqld user--with-mysqld-user=mysql-DMYSQL_USER=mysqlmysql is the default
Debugging--without-debug-DWITH_DEBUG=0default is debugging disabled
GIS support--with-geometrynonealways enabled?
Community features--enable-community-featuresnonealways enabled
Profiling--disable-profiling-DENABLE_PROFILING=0enabled by default
pstack--without-pstacknonepstack is removed
Assembler string functions--enable-assemblernone
 
Build type--build=x86_64-pc-linux-gnuno equivalentunneeded?
Cross-compile host--host=x86_64-pc-linux-gnuno equivalentunneeded?
Client flag--with-client-ldflags=-lstdc++noneunneeded
Client flag--enable-thread-safe-clientnoneunneeded, clients are always thread safe
Comment--with-comment="string"-DWITH_COMMENT="string"
 
Shared/static binaries--enable-shared --enable-staticnonethere is only DISABLE_SHARED
Memory use--with-low-memorynoneunneeded
  • 1
  • 2
  • 下一页
Oracle 的手动冷备份MySQL 5.5 自动安装脚本相关资讯      MySQL编译安装 
  • MySQL编译安装以及管理用户  (08月06日)
  • MySQL 5.7.11编译安装以及修改root  (04月15日)
  • MySQL编译安装时常见错误分析  (08/30/2015 19:38:42)
  • MySQL5.5.32编译安装  (04月27日)
  • Linux下MySQL 5.6.12数据库编译安  (03月11日)
  • RHEL5.7 64位源码编译安装MySQL-5.  (04/01/2015 10:45:53)
本文评论 查看全部评论 (0)
表情: 姓名: 字数