安裝中需要用到的軟體:mysql源碼檔案:mysql-5.5.19.tar.gzwget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.19.tar.gz/from/http://mysql.he.net/cmake(5.5版本沒用用configure編譯了)wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gzbison 不裝的話編譯時間會有警告)wget http://ftp.gnu.org/gnu/bison/bison-2.5.tar.gzGNU m4不裝無法安裝bison)http://ftp.gnu.org/gnu/m4/m4-1.4.16.tar.gzncurses-develyum安裝)gcc-c++(yum安裝)1.建YUM(因為yum可以很好解決LINUX下的依存關係)直接使用163的YUM源vi /etc/yum/pluginconf.d/fastestmirror.conf set enable=0cd /etc/yum.repos.d/wget heep://mirrors.163.com/.help/CentOS6-Base-163.repoyum makecacheyum update(如果更新有問題重新命名/lib/modules/2.6.32-71.el6.i686/kernel/net/ipv6即:mv /lib/modules/2.6.x/kernel/net/ipv6 /lib/modules/2.6.x/kernel/net/ipv6.bak 後重啟)2.相關說明1) 所有下載的檔案將儲存在 /usr/local/src/ 目錄下2) mysql 將以mysql使用者運行,而且將加入 service 開機自動運行3) mysql 將被安裝在 /usr/local/mysql/ 目錄下4) mysql 預設安裝使用 utf8 字元集5) mysql 的資料和記錄檔儲存在 /var/mysql/ 對應目錄下6) mysql 的設定檔儲存於/var/mysql/my.cnf3.安裝 cmakeyum install gcc-c++yum install ncurses-develcd /usr/local/srctar zxvf m4-1.4.16.tar.gzcd m4-1.4.16./configuremakemake installtar zxvf bison-2.5.tar.gzcd bison-2.5./configuremakemake installtar zxvf cmake-2.8.4.tar.gzcd cmake-2.8.4./bootstrapgmakegmake install 3.編譯安裝 MySQL 5.5.19groupadd mysqluseradd -g mysql mysqltar xvf mysql-5.5.19.tar.gzcd mysql-5.5.19/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \-DWITH_MYISAM_STORAGE_ENGINE=1 \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_MEMORY_STORAGE_ENGINE=1 \-DWITH_READLINE=1 \-DENABLED_LOCAL_INFILE=1 \-DMYSQL_DATADIR=/var/mysql/data \-DMYSQL_USER=mysql註:以上編譯選項意思可以看BLOG另外一篇文章)makemake installchmod +w /usr/local/mysqlchown -R mysql:mysql /usr/local/mysqlln -s /usr/local/mysql/lib/libmysqlclient.so.16 /usr/lib/libmysqlclient.so.16 mkdir -p /var/mysql/mkdir -p /var/mysql/data/mkdir -p /var/mysql/log/chown -R mysql:mysql /var/mysql/cd support-files/cp my-large.cnf /var/mysql/my.cnf註:Q:Starting MySQL..The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid)A 解決辦法:確實一般都是my.cnf設定檔的問題/etc/my.cnf來自以下檔案:如果你的記憶體≤64M,則複製/usr/local/share/mysql/my-small.cnf為/etc/my.cnf# This is for a system with little memory (<= 64M) where MySQL is only used# from time to time and it's important that the mysqld daemon# doesn't use much resources.如果記憶體是128M,則複製/usr/local/share/mysql/my-medium.cnf為/etc/my.cnf# This is for a system with little memory (32M - 64M) where MySQL plays# an important part, or systems up to 128M where MySQL is used together with# other programs (such as a web server)如果記憶體是512M,則複製/usr/local/share/mysql/my-large.cnf為/etc/my.cnf# This is for a large system with memory = 512M where the system runs mainly# MySQL.如果記憶體是1-2G,則複製/usr/local/share/mysql/my-huge.cnf為/etc/my.cnf# This is for a large system with memory of 1G-2G where the system runs mainly# MySQL. )cp mysql.server /etc/init.d/mysqld4. 配置啟動MySQL 5.5.131) 若有需要請先修改 mysql 的配置 my.cnfvi /var/mysql/my.cnf 2) mysql 初始化安裝/usr/local/mysql/scripts/mysql_install_db \--defaults-file=/var/mysql/my.cnf \--basedir=/usr/local/mysql \--datadir=/var/mysql/data \--user=mysql3)設定環境變數export PATH=/usr/local/mysql/bin:$PATH直接修改vi /etc/profile全域)或使用者目錄下.bashrc檔案 export PATH="$PATH:/usr/local/mysql/bin"或者直接添加幾個軟串連讓這些工具可以直接用,如下ln -s /usr/local/mysql/bin/mysql /usr/binln -s /usr/local/mysql/bin/mysqldump /usr/binln -s /usr/local/mysql/bin/mysqladmin /usr/bin4)將 mysql 加入開機啟動cp support-files/mysql.server /etc/init.d/mysqldchmod +x /etc/init.d/mysqldvi /etc/init.d/mysqld 編輯此檔案,尋找並修改以下變數內容:)basedir=/usr/local/mysqldatadir=/var/mysql/datachkconfig --add mysqldchkconfig --level 345 mysqld on5)啟動 mysqlservice mysqld start