Mysql编译安装参数优化

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 -prefix=/data/app/mysql5123  --datadir=/data/mysqldata --sysconfdir=/data/app/mysql5123/etc --with-charset=utf8 --enable-assembler  --without-isam --with-pthread --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --with-extra-charsets=all --with-unix-socket-path=/data/app/mysql5123/tmp/mysql.sock 

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

2、编译安装MySQL 5.0.45/Mysql4.0.26(现在以mysql5为例)

/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
tar zxvf mysql-5.0.45.tar.gz
cd mysql-5.0.45
./configure –prefix=/usr/local/webserver/mysql/ –without-debug –with-unix-socket-path=/tmp/mysql.sock –with-client-ldflags=-all-static –with-mysqld-ldflags=-all-static –enable-assembler –with-extra-charsets=gbk,gb2312,utf8 –with-pthread –enable-thread-safe-client
make && make install
chmod +w /usr/local/webserver/mysql
chown -R mysql:mysql /usr/local/webserver/mysql
cp support-files/my-medium.cnf /usr/local/webserver/mysql/my.cnf
cd ../

附:以下为附加步骤,如果你想在这台服务器上运行MySQL数据库,则执行以下两步。如果你只是希望让PHP支持MySQL扩展库,能够连接其他服务器上的MySQL数据库,那么,以下两步无需执行。
①、以mysql用户帐号的身份建立数据表:

/usr/local/webserver/mysql/bin/mysql_install_db –defaults-file=/usr/local/webserver/mysql/my.cnf –basedir=/usr/local/webserver/mysql –datadir=/usr/local/webserver/mysql/data –user=mysql –pid-file=/usr/local/webserver/mysql/mysql.pid –skip-locking –port=3306 –socket=/tmp/mysql.sock

②、启动MySQL(最后的&表示在后台运行)

/bin/sh /usr/local/webserver/mysql/bin/mysqld_safe –defaults-file=/usr/local/webserver/mysql/my.cnf &

 

本文来自于:

http://www.cnblogs.com/hemhem/archive/2011/03/14/2087481.html

你可能感兴趣的:(优化,mysql,数据库,职场,休闲)