mysql編譯參數

 

安裝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端口

You May Also Like