Home >Database >Mysql Tutorial >Linux下编译安装Mysql 5.5的简单步骤_MySQL

Linux下编译安装Mysql 5.5的简单步骤_MySQL

WBOY
WBOYOriginal
2016-06-01 12:59:20910browse

首先是安装cmake环境。因为博主测试机是ubuntu,所以直接用apt-get install cmake命令来安装,yum相信应该也一样。或者可以编译安装,步骤如下。

代码如下:


wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz
tarx zvfc cmake-2.8.12.2.tar.gz
cd cmake-2.8.12.2
 ./configure
make && make install

安装完成后执行cmake -version,确定已经正确安装。

然后下载mysql最新源码包,编译安装。

代码如下:


wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.36.tar.gz
tar xzvf mysql-5.5.36.tar.gz
cd mysql-5.5.36
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql
make && make install

这里博主遇到一个有关ssl的错误,提示信息如下所示。

Linking C shared module adt_null.so
[ 65%] Built target audit_null
Scanning dependencies of target vio
[ 65%] Building C object vio/CMakeFiles/vio.dir/vio.c.o
[ 65%] Building C object vio/CMakeFiles/vio.dir/viosocket.c.o
[ 65%] Building C object vio/CMakeFiles/vio.dir/viossl.c.o
/root/mysql-5.5.36/vio/viossl.c: In function ‘ssl_do':
/root/mysql-5.5.36/vio/viossl.c:175: error: ‘SSL_OP_NO_COMPRESSION' undeclared (first use in this function)
/root/mysql-5.5.36/vio/viossl.c:175: error: (Each undeclared identifier is reported only once
/root/mysql-5.5.36/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

最后发现这个问题的原因是mysql5.5无法在openssl-1.0.0及更低版本下编译导致的。如果不需要ssl可以去掉WITH_SSL配置项,也可以升级openssl的版本,另外更方便的方法可以在cmake之前打一个补丁。

代码如下:


wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.36.tar.gz
tar xzvf mysql-5.5.36.tar.gz
cd mysql-5.5.36
wget -c "http://bugs.mysql.com/file.php?id=19941&bug_id=68999" -O mysql-openssl.patch
patch -p1 mysql-openssl.patch

最后复制配置文件、修改。

代码如下:


cp support-files/my-medium.cnf /etc/my.cnf
sed '/skip-external-locking/i\datadir = /data/mysql' -i /etc/my.cnf
sed -i 's:#innodb:innodb:g' /etc/my.cnf
sed -i 's:/usr/local/mysql/data:/data/mysql:g' /etc/my.cnf

启动mysql,成功!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn