首页 » my » 正文

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 
允许使用汇编模式(优化性能)

yum install ncurses-devel(必须安装,否则在configure的时候会报错)

 

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

groupadd mysql

useradd -g mysql mysql

cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf

sed -i 's/skip-locking/skip-external-locking/g' /etc/my.cnf

/usr/local/mysql/bin/mysql_install_db –user=mysql

chown -R mysql /usr/local/mysql/var

chgrp -R mysql /usr/local/mysql/.

cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql

chmod 755 /etc/init.d/mysql

chkconfig –level 345 mysql on

echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf

echo "/usr/local/lib" >>/etc/ld.so.conf

 

ldconfig

ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql

ln -s /usr/local/mysql/include/mysql /usr/include/mysql

/etc/init.d/mysql start

 

/usr/local/mysql/bin/mysqladmin -u root password $mysqlrootpwd

 

/etc/init.d/mysql restart