mysql編譯安裝及其各參數詳解、常見錯誤分析

環境:yum install make gcc gcc-c++ libxml2 libxml2-devel libmcrypt libmcrypt-devel libtool-ltdl apr apr-* ncurses ncurses-*
安裝mysql:
#tar -zxvf mysql-5.1.53.tar.gz
#cd mysql-5.1.53
#/usr/sbin/groupadd mysql
#/usr/sbin/useradd mysql -g mysql
#./configure –prefix=/opt/mysql –localstatedir=/opt/mysql/data/ –with-server-suffix=-enterprise-gpl –without-debug –with-big-tables –with-extra-charsets=gb2312,utf8,GBK –with-extra-charsets=all –with-pthread –enable-thread-safe-client –enable-static –with-client-ldflags=-all-static –with-mysqld-ldflags=-all-static –enable-assembler –without-innodb –without-ndb-debug –without-isam
#make(時間會很長、優化的比較多)
#make install
#mkdir –p /opt/mysql/data
#cd /opt/mysql
#bin/mysql_install_db –user=mysql
註:Installing MySQL system tables…
OK
Filling help tables…
OK
 
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
 
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
 
/opt/mysql/bin/mysqladmin -u root password 'new-password'
/opt/mysql/bin/mysqladmin -u root -h xsl228 password 'new-password'
 
Alternatively you can run:
/opt/mysql/bin/mysql_secure_installation
 
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
 
See the manual for more instructions.
 
You can start the MySQL daemon with:
cd /opt/mysql ; /opt/mysql/bin/mysqld_safe &
 
You can test the MySQL daemon with mysql-test-run.pl
cd /opt/mysql/mysql-test ; perl mysql-test-run.pl
 
Please report any problems with the /opt/mysql/bin/mysqlbug script!
#chown -R mysql.mysql .
#chown -R mysql.mysql /opt/mysql/data
#cp share/mysql/my-medium.cnf /etc/my.cnf
#cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld
#chmod 755 /etc/rc.d/init.d/mysqld
#/opt/mysql/bin/mysqld_safe –user=mysql &
如果mysql不成功,查看下mysql的錯誤日志
Mysql常見錯誤:
1.[Warning] '–skip-locking' is deprecated and will be removed in a future release. Please use '–skip-external-locking' instead.
解決方式:#vi /etc/my.cnf 將skip-locking註釋掉,然後添加一行:skip-external-locking
2. 110830 23:38:05 [ERROR] Aborting
110830 23:38:05 [Note] /opt/mysql/libexec/mysqld: Shutdown complete
110830 23:38:05 mysqld_safe mysqld from pid file /opt/mysql/data/xsl231.pid ended
110830 23:38:09 mysqld_safe Starting mysqld daemon with databases from /opt/mysql/data
/opt/mysql/libexec/mysqld: File './mysql-bin.index' not found (Errcode: 13)
解決方式:初始化的時候添加bin/mysql_install_db –user=mysql
啟動的時候:/opt/mysql/bin/mysqld_safe –user=mysql &
(–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-thread-safe-client 以線程方式編譯客戶端
–enable-static
–with-client-ldflags=-all-static
–with-mysqld-ldflags=-all-static
以靜態方式編譯客戶端和服務端,能提高13%性能
–enable-assembler 使用一些字符函數來匯編版本
–without-ndb-debug 取消導航調試
–without-innodb
去掉innodb表支持,innodb是一種支持事務處理的表,適合企業級應用
–with-plugins=innobase 存儲引擎,從mysql5.1開始,編譯參加innodb插件就從
–with-innodb改成瞭—with-plugins=innobase)

 
本文出自 “Just do it !” 博客

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *