linux mysql 编译安装参数详解_Linux系统下mysql安装时的常用编译参数

转载:

我们经常需要安装mysql,二进制编译时,我们该加什么参数呢?这里我们总结出了常用的配置参数分享给大家!

SQL Code复制内容到剪贴板

./configure \

--prefix=/web/mysql --sysconfdir=/web/mysql    \

--without-debug     --enable-assembler         \

--with-mysqld-ldflags=-all-static              \

--with-client-ldflags=-all-static              \

--with-unix-socket-path=/tmp/mysql.sock        \

--with-mysqld-user=mysql                       \

--with-extra-charsets=utf8,gbk,gb2312          \

--with-innodb                                  \

--with-mysqld-user=mysql                       \

--with-charset=utf8 --with-collation=utf8_unicode_ci

---------------------------------------------------------

如果需要支持表分区, 需要添加--with-partition

上面是一个简单的常用编译时加的参数,下面我们将实际的告诉大家怎么具体加这些参数的意义:

安装MySQL安装前确认以下包已经装好gcc gcc-c++ ncurses-devel

/usr/sbin/groupadd mysql

/usr/sbin/useradd -g mysql mysql

tar zxvf mysql-5.4.0-beta.tar.gz

cd mysql-5.4.0-beta

CFLAGS="-O6 -mpentiumpro -fomit-frame-pointer" CXX=gcc CXXFLAGS="-O6

-mpentiumpro -fomit-frame-pointer -felide-constructors -fno-exceptions

-fno-rtti"

./configure --prefix=/usr/local/mysql

--localstatedir=/usr/local/mysql/var/

--with-server-suffix=-enterprise-gpl --without-debug --with-big-tables

--with-extra-charsets=latin1,gb2312,big5,utf8,GBK

--with-extra-charsets=all --with-pthread --enable-static

--enable-thread-safe-client --with-client-ldflags=-all-static

--with-mysqld-ldflags=-all-static --enable-assembler --without-innodb

--without-ndb-debug --without-isam --with-federated-storage-engine

make && make install

cp support-files/my-medium.cnf /usr/local/mysql/my.cnf

/usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

my.cnf文件记得注销--skip-federated引擎功能再启动mysql

./mysqld_safe --defaults-file=/usr/local/mysql/my.cnf --user=mysql &

mysql编译参数说明:根据 ./configure --help 查看支持配置的参数

-pgcc和-O6编译

CFLAGS="-O6 -mpentiumpro -fomit-frame-pointer" CXX=gcc CXXFLAGS="-O6

-mpentiumpro -fomit-frame-pointer -felide-constructors -fno-exceptions

-fno-rtti"

总体性能可提高10%,当然如果服务器不是用奔腾处理器,就不必用它了,因为它是专为奔腾系统设计的

-static静态编译

--enable-static

--with-client-ldflags=-all-static

--with-mysqld-ldflags=-all-static

以静态方式编译客户端和服务端,能提高13%性能

--enable-thread-safe-client

以线程方式编译客户端

--without-innodb

去掉innodb表支持,innodb是一种支持事务处理的表,适合企业级应用

--without-isam

去掉isam表类型支持,现在很少用了,isam表是一种依赖平台的表

--without-ndb-debug

取消导航调试

--localstatedir=/usr/local/mysql/var/

日志文件目录

--with-server-suffix=-enterprise-gpl

给MySQL加个后缀名,在用mysql登录的时候在版本号的后面可以看到

--without-debug

去除诊断模式,如果用--with-debug=full编译,大多数查询慢20%

--with-big-tables

大表支持

--with-extra-charsers=gbk,gb2312,utf8

设置支持gbk,gb2312,utf8字符集

--with-pthread

强制使用pthread库(posix线程库)

--enable-assembler

使用一些字符函数来汇编版本

--with-federated-storage-engine

这个参数已经被废除,代替它的是--with-plugin系列

cp support-files/my-medium.cnf /usr/local/mysql/my.cnf

mysql/support-files里面有配置文件范本,根据实际情况选择或者更改

/usr/local/mysql/bin/mysql_install_db

--basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

--defaults-file=/usr/local/mysql/my.cnf

--pid-file=/usr/local/mysql/mysql.pid

设定默认值:默认空间路径;默认数据文件路径;默认用户;默认配置文件路径;默认PID文件路径。

-------------------------------------------------------

本脚步未加入的编译参数:

--with-charset=utf8

设置默认字符集

--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock

使用unix套接字链接提高7.5%性能,所以在windows下mysql性能肯定不如 unix

--with-tcp-port=3306

指定MySQL实例将监听TCP 3306端口

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值