RHEL5.7 64位源碼編譯安裝MySQL-5.5.42遇到的問題

來源:互聯網
上載者:User

RHEL5.7 64位源碼編譯安裝MySQL-5.5.42遇到的問題

由於MySQL從5.5之後的版本源碼編譯安裝用cmake, make, make install安裝,不用./Configure,make,make install 安裝,所以要看下系統是不是有cmake這個命令,紅帽企業版5預設是沒有安裝的,所以要手動安裝(紅帽6已預設安裝)。cmake安裝方法在網上搜下就行。

    安裝Mysql官方給的方法如下:

# Preconfiguration setup
shell> groupadd mysql
shell> useradd -r -g mysql mysql
# Beginning of source-build specific instructions
shell> tar zxvf mysql-VERSION.tar.gz
shell> cd mysql-VERSION
shell> cmake .
shell> make
shell> make install
# End of source-build specific instructions
# Postinstallation setup
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

自己編譯的時候後面加了參數:
    cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mydata -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci


在執行make時編譯失敗:
[ 69%] Building C object vio/CMakeFiles/vio.dir/viossl.c.o
/root/mysql-5.5.42/vio/viossl.c: In function assl_doa:
/root/mysql-5.5.42/vio/viossl.c:175: error: aSSL_OP_NO_COMPRESSIONa undeclared (first use in this function)
/root/mysql-5.5.42/vio/viossl.c:175: error: (Each undeclared identifier is reported only once
/root/mysql-5.5.42/vio/viossl.c:175: error: for each function it appears in.)
make[2]: *** [vio/CMakeFiles/vio.dir/viossl.c.o] Error 1
make[1]: *** [vio/CMakeFiles/vio.dir/all] Error 2
make: *** [all] Error 2
    這個為openssl版本太低的原因,mysql5.5無法在openssl-1.0.0及更低版本下編譯導致的。查看了下openssl的版本為openssl-0.9.8,openssl version -a.
    如果不需要ssl可以去掉WITH_SSL配置項,也可以升級openssl的版本,另外更方便的方法可以在cmake之前打一個補丁。
    升級openssl:
    從ftp://ftp.openssl.org/source/下載
    tar -xvf openssl-1.0.2a.tar.gz
    cd openssl-1.0.2a
    ./config shared zlib
    make
    make install

    mv /usr/bin/openssl /tmp/
    ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
    ln -s /usr/local/ssl/include/openssl/ /usr/include/openssl
    echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
    ldconfig -v | grep openssl
    查看版本:

    openssl version -a
重新編譯:
    先執行:
    make clean

    rm CMakeCache.txt
然後重頭再來,發現還是不成功(升級後還不成功到底啥原因呢?)。最後把-DWITH_SSL=system 這項去掉編譯成功。
下面為去掉DWITH_SSL=system的參數:
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mydata -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

--------------------------------------分割線 --------------------------------------

Ubuntu 14.04下安裝MySQL

《MySQL權威指南(原書第2版)》清晰中文掃描版 PDF

Ubuntu 14.04 LTS 安裝 LNMP Nginx\PHP5 (PHP-FPM)\MySQL

Ubuntu 14.04下搭建MySQL主從伺服器

Ubuntu 12.04 LTS 構建高可用分布式 MySQL 叢集

Ubuntu 12.04下原始碼安裝MySQL5.6以及Python-MySQLdb

MySQL-5.5.38通用二進位安裝

--------------------------------------分割線 --------------------------------------

本文永久更新連結地址:

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.