MySQL-8.0.12源码安装实例

  1. 云栖社区>
  2. 博客>
  3. 正文

MySQL-8.0.12源码安装实例

初雪之路 2018-11-16 16:57:36 浏览1983
展开阅读全文

1、通过官网下载对应的版本后,通过FTP上传至云服务器的/usr/local/src 目录

2、解压缩文件

[root@JSH-01 src]# ls
mysql-boost-8.0.12.tar.gz
[root@JSH-01 src]# tar zxvf mysql-boost-8.0.12.tar.gz
[root@JSH-01 src]# ls
mysql-8.0.12  mysql-boost-8.0.12.tar.gz

3、重命名文件夹

[root@JSH-01 src]# mv mysql-8.0.12  mysql
[root@JSH-01 src]# ls
mysql  mysql-boost-8.0.12.tar.gz
[root@JSH-01 src]# cd mysql
[root@JSH-01 mysql]# ls
boost           config.h.cmake    Doxyfile.in        libbinlogevents      man         plugin             sql            testclients  win
client          configure.cmake   doxygen_resources  libbinlogstandalone  mysql-test  README             sql-common     unittest
cmake           dbug              extra              libmysql             mysys       run_doxygen.cmake  storage        utilities
CMakeLists.txt  Docs              include            libservices          mysys_ssl   scripts            strings        VERSION
components      Doxyfile-ignored  INSTALL            LICENSE              packaging   share              support-files  vio

4、安装cmake工具 yum install -y cmake

5、cmake构建编译环境

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/src/mysql  -DMYSQL_DATADIR=/usr/local/src/mysql/var  -DSYSCONFDIR=/usr/local/src/mysql/etc -DWITH_DEBUG=0  -DWITH_INNODB_MEMCACHED=1  -DWITH_PARTITION_STORAGE_ENGINE=1  -DENABLED_PROFILING=0  -DCMAKE_C_FLAGS="-O3"  -DCMAKE_CXX_FLAGS="-O3"

6、cmake报错汇总:

错误1、 CMake Warning at CMakeLists.txt:185 (MESSAGE):
  Could not find devtoolset gcc

解决方案:yum install -y gcc

再次执行cmake编译

错误2、**-- Could NOT find Git (missing:  GIT_EXECUTABLE) **

解决方案:yum install -y git

错误3、-- The CXX compiler identification is unknown
CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.

解决方案:yum install -y gcc gcc-c++

再次执行cmake编译

错误4、CMake Error at cmake/boost.cmake:101 (MESSAGE):
  You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>

解决方案:编译选项中增加
-DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/src/mysql
回车后,系统会自动下载并解压缩该文件

错误5、Cannot find appropriate system libraries for WITH_SSL=system.
Make sure you have specified a supported SSL version. 
Valid options are : 
system (use the OS openssl library), 
yes (synonym for system), 
</path/to/custom/openssl/installation>, 
wolfssl (use wolfSSL. See extra/README-wolfssl.txt on how to set this up)

错误6、CMake Error at cmake/ssl.cmake:68 (MESSAGE):
  Please install the appropriate openssl developer package.

解决方案5:编译选项中增加 -DWITH_SSL=system

解决方案6:yum install ncurses-devel 和 yum install openssl-devel

7、执行编译 make -j N(N为线程数,一般为服务器中CPU的个数)

查看Linux系统CPU信息:

cat /proc/cpuinfo

查看Linux系统CPU物理个数:

cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l

8、cmake -j 编译过程中的错误信息

[ 56%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/handler/i_s.cc.o
错误  c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
make[2]: *** [storage/innobase/CMakeFiles/innobase.dir/handler/handler0alter.cc.o] Error 4
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [storage/innobase/CMakeFiles/innobase.dir/all] Error 2
make: *** [all] Error 2

解决方案:根据错误信息提示 internal compiler error: Killed (program cc1plus) 判断为编译过程中内存耗尽, 导致了编译中断,解决办法就是增加一个交换分区:

[root@JSH-01 mysql]# dd if=/dev/zero of=/swapfile bs=1k count=2048000    //创建分区文件, 大小 2G
2048000+0 records in
2048000+0 records out
2097152000 bytes (2.1 GB) copied, 16.9483 s, 124 MB/s
[root@JSH-01 mysql]# mkswap /swapfile   //生成 swap 文件系统
Setting up swapspace version 1, size = 2047996 KiB
no label, UUID=5c0b0fa8-7396-4b89-998f-29b6b269a938
[root@JSH-01 mysql]# swapon /swapfile   //激活 swap 文件
swapon: /swapfile: insecure permissions 0644, 0600 suggested.

网友评论

登录后评论
0/500
评论
初雪之路
+ 关注