mysql 编译安装与编译参数 添加mysql组和mysql用户 [root@centos mysql]# groupadd mysql [root@centos mysql]# useradd -g mysql mysql 编译与安装 tar -zxvf mysql-5.1.35.tar.gz ./configure \ --prefix=/usr/local/mysql \ --localstatedir=/data/mysql/data \ mysql数据目录 --enable-assembler \ 允许使用汇编模式(优化性能) --with-unix-socket-path=/tmp/mysql.sock 使用unix套接字链接提高 --enable-thread-safe-client \以线程方式编译客户端 线程安全 --with-client-ldflags=-all-static \ 以纯静态方式编译客户端 --with-mysqld-ldflags=-all-static 以纯静态方式编译服务端 --with-plugins=partition,innobase 支持引擎 --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all --with-big-tables 支持大数据库表 --without-debug 去除debug模式
make && make install chmod +w /opt/mysql chown -R mysql:mysql /opt/mysql/ /opt/mysql/bin/mysql_install_db --user=mysql /opt/mysql/bin/mysqld_safe --user=mysql &
mysql目录权限设置 mkdir /usr/local/mysql/var mkdir /var/run/mysqld chmod +w /usr/local/mysql/ chown -R mysql:mysql /usr/local/mysql/ chown -R mysql:mysql /var/run/mysqld cp /usr/local/mysql/share/mysql/my-innodb-heavy-4G.cnf /etc/my.cnf 以mysql用户初始化数据库表 /usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql/data --user=mysql --datadir=/data/mysql/data 定义mysql数据存放目录 注意:如果把数据目录定义到其它目录里,得先修改/etc/my.cnf文件,加上以下二行 [mysqld] # generic configuration options port = 3306 socket = /tmp/mysql.sock # wb config basedir = /usr/local/mysql 字义mysql程序目录 datadir = /data1/mysql/data 定义数据目录 在对数据库进行初始化表,不然mysql数据库启动会报错. 启动mysql服务 /usr/local/mysql/bin/mysqld_safe --user=mysql --datadir=/data/mysql/data (指定数据库目录) /usr/local/mysql/bin/mysqld_safe --user=mysql 2>&1 > /dev/null &
1. -static 13% --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static 静态链接提高13%性能
2. -pgcc 1% CFLAGS="-O3 -mpentiumpro -mstack-align-double" CXX=gcc \ CXXFLAGS="-O3 -mpentiumpro -mstack-align-double \ -felide-constructors -fno-exceptions -fno-rtti" 如果是Inter处理器,使用pgcc提高1%性能
3. Unix Socket 7.5% --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock 使用unix套接字链接提高7.5%性能,所以在windows下mysql性能肯定不如unix下面
4. --enable-assembler 允许使用汇编模式(优化性能) 下面是总体的编译文件
编译代码 CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors \ -fno-exceptions -fno-rtti -fomit-frame-pointer -ffixed-ebp" ./configure \ --prefix=/usr/local/mysql --enable-assembler \ --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all
编译MySQL的过程中提示: /bin/rm: cannot remove `libtoolt': No such file or directory 解决: 1、确认libtool是否已经安装,如果没有安装的话,则先安装libtool # yum -y install libtool 2、分别执行以下三条命令: # autoreconf --force --install # libtoolize --automake --force # automake --force --add-missing
CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti -fomit-frame-pointer -ffixed-ebp" ./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-unix-socket-path=/tmp/mysql.sock --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all --with-pthread --with-plugins=all
常用apache编译参数说明
查看源代码打印帮助1 prefix 指定安装目录
2 enable-rewrite 支持 URL 重写
3 enable-deflate 支持网页压缩
4 enable-speling 纠正常见的URL拼写错误
5 enable-ssl SSL/TLS support (mod_ssl)
6 with-module 加载模块
常用mysql编译参数说明
查看源代码打印帮助1 enable-assembler 使用一些字符函数来汇编版本
2 with-extra-charsets=complex 使用的字符集为默认(无,复杂的,所有,或从上述设置选定的名单)
3 enable-thread-safe-client 让客户端支持线程
4 with-big-tables 大表支持
5 with-readline Use system readline instead of bundled copy
6 with-ssl Include SSL support
7 with-embedded-server 编译成embedded MySQL library (libmysqld.a)
8 enable-local-infile 让mysql支持从本地文件 导入数据库
9 with-plugins=innobase 存储引擎
10 with-charset=utf8 设置默认字符集
11 with-collation=utf8_general_ci 设置字符集校验规则
常用PHP编译参数说明
查看源代码打印帮助1 with-config-file-path 指定php.ini位置
2 with-apxs2 整合 apache,apxs功能是使用mod_so中的LoadModule指令,加载指定模块到 apache,要求 apache 要打开SO模块
3 with-mysql mysql安装目录,对mysql的支持
4 with-mysqli mysqli文件目录,优化支持
5 with-iconv-dir iconv函数,对字符集间的转换
6 with-freetype-dir 打开对freetype字体库的支持
7 with-jpeg-dir 打开对jpeg图片的支持
8 with-png-dir 打开对png图片的支持
9 with-zlib 打开zlib库的支持
10 with-libxml-dir 打开libxml2库的支持
11 enable-xml 打开xml的支持
12 enable-inline-optimization 优化线程
13 with-curl 打开curl浏览工具的支持
14 with-curlwrappers 运用curl工具打开url流
15 enable-mbregex 打开对mbregex的支持
16 enable-mbstring 多字节,字符串的支持
17 with-mcrypt 算法
18 with-gd 打开gd库的支持
19 enable-gd-native-ttf 支持TrueType字符串函数库
20 with-openssl openssl的支持,加密传输时用到的
21 with-mhash 算法
22 enable-pcntl freeTDS需要用到的,可能是链接mssql 才用到
23 enable-sockets 打开 sockets 支持
24 with-ldap Include LDAP support
25 with-ldap-sasl LDAP: Include Cyrus SASL support
26 with-xmlrpc 打开xml-rpc的c语言
27 enable-zip 打开对zip的支持
28 enable-soap Enable SOAP support
29 with-gettext 打开gnu 的gettext 支持,编码库用到
30 -----------------------------------------------------------
31 enable-track-vars
32 在php做web脚本时候有用,在GET/POST/Cookie里追踪php变量。 大概是由于安全性原因,较新版本的php已经废弃了这个编译选项
|