源码安装mysql-8.0.15.tar.gz

准备环境
1、安装确保以下系统相关库文件
gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel libmcrypt* libtool*(libtool-ltdl-devel*)

# yum –y install gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel libmcrypt* libtool* cmake
# yum  install gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel libmcrypt* libtool* cmake(不建议用-y参数,)

2、 建立mysql安装目录及数据存放目录

# mkdir  /usr/local/mysql
# mkdir  -p /data/mysql

3、 创建用户和用户组

# groupadd mysql
# useradd -g mysql mysql

4、 赋予数据存放目录权限

# chown mysql.mysql –R /data/mysql

二、安装mysql-8.0.15.tar.gz
1、 获取解压mysql-8.0.15.tar.gz
在mysql.com官网或国内镜像下载源码

# wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-8.0/mysql-8.0.15.tar.gz
# tar zxvf mysql-8.0.15.tar.gz
# cd mysql-8.0.15

2、 编译cd mysql-8.0.15
报错 需要先安装cmake命令

# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DCMAKE_C_COMPILER=/opt/rh/devtoolset-4/root/usr/bin/gcc -DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-4/root/usr/bin/g++
-DMYSQL_UNIX_ADDR=/tmp/mysqld.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=/data/mysql \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306

错误1 Could NOT find Git Could not find devtoolset gcc

[root@localhost mysql-8.0.15]#  cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysqld.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=/data/mysql -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306
-- Running cmake version 2.8.12.2
-- Could NOT find Git (missing:  GIT_EXECUTABLE) 
-- This is Linux version 2.6.32-754.el6.x86_64
-- We probably need some devtoolset compiler
CMake Warning at CMakeLists.txt:178 (MESSAGE):
  Could not find devtoolset gcc

解决
yum install git

错误2 Could not find devtoolset gcc

root@localhost mysql-8.0.15]#  cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysqld.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=/data/mysql -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306
-- Running cmake version 2.8.12.2
-- Found Git: /usr/bin/git (found version "1.7.1") 
-- This is Linux version 2.6.32-754.el6.x86_64
-- We probably need some devtoolset compiler
CMake Warning at CMakeLists.txt:178 (MESSAGE):
  Could not find devtoolset gcc


-- MySQL 8.0.15
-- Source directory /home/admin/桌面/mysql-8.0.15
-- Binary directory /home/admin/桌面/mysql-8.0.15
-- CMAKE_GENERATOR: Unix Makefiles
CMake Error at cmake/os/Linux.cmake:50 (MESSAGE):
  GCC 4.8.3 or newer is required (-dumpversion says 4.4.7)
Call Stack (most recent call first):
  CMakeLists.txt:367 (INCLUDE)


-- Configuring incomplete, errors occurred!
See also "/home/admin/桌面/mysql-8.0.15/CMakeFiles/CMakeOutput.log".
See also "/home/admin/桌面/mysql-8.0.15/CMakeFiles/CMakeError.log".

解决
http://www.senra.me/install-devtools-for-centos-to-get-high-version-gcc/
Centos6安装devtoolset(高版本gcc)——工欲善其事,必先利其器
一.缘由
Centos6这老旧的软件源真是每次都让我碰到问题……然而我依旧爱它爱的那样深沉(滑稽),好吧,主要是我懒得换_(:з」∠)_,毕竟人是恋旧的(大滑稽),额,我吹不下去了。事实就是Aria2要求gcc 4.8以上的版本才能编译,然而Centos6源里的gcc版本才4.4,所以升级gcc就成了头号问题。

二.走起
问题发现了那就要解决,常规的方法都是编译,然而……GCC这玩意编译起来真的是要命啊,高配机器还好,低配的那简直了,我选择死亡,所以我直接扭头就跑,然后发现了devtoolset,字面上可以理解为开发工具集,主要就是一大堆版本较新的编译器啥的,当然也有GCC和G++这俩,OK,那么问题就好办了,装起来

①GCC 4.7

wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo -O /etc/yum.repos.d/devtools-1.1.repo
yum --enablerepo=testing-1.1-devtools-6 install devtoolset-1.1-gcc devtoolset-1.1-gcc-c++

以下为编译前使用

export CC=/opt/centos/devtoolset-1.1/root/usr/bin/gcc export
CPP=/opt/centos/devtoolset-1.1/root/usr/bin/cpp export
CXX=/opt/centos/devtoolset-1.1/root/usr/bin/c++

以下为替换系统GCC

ln -s /opt/rh/devtoolset-1.1/root/usr/bin/* /usr/local/bin/ 
hash -r 
gcc --version

②.GCC 4.8

wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo

yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++


以下为替换系统GCC

export CC=/opt/rh/devtoolset-2/root/usr/bin/gcc export
CPP=/opt/rh/devtoolset-2/root/usr/bin/cpp export
CXX=/opt/rh/devtoolset-2/root/usr/bin/c++

以下为替换系统GCC

ln -s /opt/rh/devtoolset-2/root/usr/bin/* /usr/local/bin/ 
hash -r 
gcc --version

③.GCC 4.9

wget https://copr.fedoraproject.org/coprs/rhscl/devtoolset-3/repo/epel-6/rhscl-devtoolset-3-epel-6.repo -O /etc/yum.repos.d/devtools-3.repo
yum install devtoolset-3-gcc devtoolset-3-binutils devtoolset-3-gcc-c++

其它参照①、②命令,替换目录就行

④.GCC 5.2

wget https://copr.fedoraproject.org/coprs/hhorak/devtoolset-4-rebuild-bootstrap/repo/epel-6/hhorak-devtoolset-4-rebuild-bootstrap-epel-6.repo -O /etc/yum.repos.d/devtools-4.repo
yum install devtoolset-4-gcc devtoolset-4-binutils devtoolset-4-gcc-c++

其它参照①、②命令,替换目录就行

安装的GCC都在/opt/rh/devtoolset-*中,有其它需要可以自己处理

Tags: aria2, gcc, rpm, 编译器

Senraの小窝原创文章,转载请注明来自:Centos6安装devtoolset(高版本gcc)——工欲善其事,必先利其器

错误2 Please do not build in-source. Out-of source builds are highly

-- MySQL 8.0.15
-- The C compiler identification is GNU 4.4.7
-- The CXX compiler identification is GNU 4.4.7
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Source directory /home/admin/桌面/mysql-8.0.15
-- Binary directory /home/admin/桌面/mysql-8.0.15
CMake Error at CMakeLists.txt:283 (MESSAGE):
  Please do not build in-source.  Out-of source builds are highly
  recommended: you can have multiple builds for the same source, and there is
  an easy way to do cleanup, simply remove the build directory (note that
  'make clean' or 'make distclean' does *not* work)

  You *can* force in-source build by invoking cmake with
  -DFORCE_INSOURCE_BUILD=1


-- Configuring incomplete, errors occurred!
See also "/home/admin/桌面/mysql-8.0.15/CMakeFiles/CMakeOutput.log".
See also "/home/admin/桌面/mysql-8.0.15/CMakeFiles/CMakeError.log".

解决

rm CMakeCache.txt
vim CMakeLists.txt
:set number

给283行的判断加注解就行

271
272 # https://gitlab.kitware.com/cmake/community/wikis/FAQ
273 # cmake-does-not-generate-a-make-distclean-target-why
274 # Why disallow in-source build?
275 # Basically because ‘make clean’ or ‘make distclean’ do not work.
276 # So if you do a ‘git pull’ you may end up with a developer sandbox
277 # that no longer works as expected (CMakeCache.txt and other
278 # generated/configured files may contain data which is no longer valid)
279 #IF(${REALPATH_CMAKE_SOURCE_DIR} STREQUAL ${REALPATH_CMAKE_BINARY_DIR})
280 # IF(FORCE_INSOURCE_BUILD)
281 # MESSAGE(WARNING “This is an in-source build”)
282 # ELSE()
283 # MESSAGE(FATAL_ERROR
284 # "Please do not build in-source. "
285 # "Out-of source builds are highly recommended: "
286 # "you can have multiple builds for the same source, "
287 # "and there is an easy way to do cleanup, "
288 # "simply remove the build directory "
289 # "(note that ‘make clean’ or ‘make distclean’ does not work) "
290 # “\nYou can force in-source build by invoking cmake with -DFORCE_INSOURCE_BUILD=1”)
291 # ENDIF()
292 #ENDIF()
293

或者
改变构建路径

cmake ./mysql-8.0.15/  -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysqld.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=/data/mysql -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306

错误4 GCC 4.8.3 or newer is required (-dumpversion says 4.4.7)

继续运行报错

[root@localhost mysql-8.0.15]#  cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysqld.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=/data/mysql -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306
-- Running cmake version 2.8.12.2
-- MySQL 8.0.15
-- Source directory /home/admin/桌面/mysql-8.0.15
-- Binary directory /home/admin/桌面/mysql-8.0.15
-- CMAKE_GENERATOR: Unix Makefiles
CMake Error at cmake/os/Linux.cmake:50 (MESSAGE):
  GCC 4.8.3 or newer is required (-dumpversion says 4.4.7)
Call Stack (most recent call first):
  CMakeLists.txt:367 (INCLUDE)


-- Configuring incomplete, errors occurred!
See also "/home/admin/桌面/mysql-8.0.15/CMakeFiles/CMakeOutput.log".
See also "/home/admin/桌面/mysql-8.0.15/CMakeFiles/CMakeError.log".
[root@localhost mysql-8.0.15]# 

解决
https://stackoverflow.com/questions/54338555/installing-from-source-could-not-find-devtoolset-gcc
附加到您的cmake行: -DCMAKE_C_COMPILER=/opt/rh/devtoolset-7/root/usr/bin/gcc -DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-7/root/usr/bin/g++

错误 Could not find (the correct version of) boost.

cmake ./mysql-8.0.15/ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DCMAKE_C_COMPILER=/opt/rh/devtoolset-4/root/usr/bin/gcc -DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-4/root/usr/bin/g++
-DMYSQL_UNIX_ADDR=/tmp/mysqld.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=/data/mysql \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306

报错

	-- Could not find (the correct version of) boost.
	-- MySQL currently requires boost_1_68_0

CMake Error at cmake/boost.cmake:102 (MESSAGE):
  You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=

  This CMake script will look for boost in .  If it is not there,
  it will download and unpack it (in that directory) for you.

  If you are inside a firewall, you may need to use an https proxy:

  export https_proxy=http://example.com:80

Call Stack (most recent call first):
  cmake/boost.cmake:259 (COULD_NOT_FIND_BOOST)
  CMakeLists.txt:773 (INCLUDE)

解决
根据提示

    You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=

cmake ./mysql-8.0.15/  -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/boot/ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysqld.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=/data/mysql -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306

又报错 boot 内存不够 换个路径

cmake ./mysql-8.0.15/  -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/home/admin/桌面/ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysqld.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=/data/mysql -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306

错误Cannot find appropriate system libraries for WITH_SSL=system.

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), 
, 
wolfssl (use wolfSSL. See extra/README-wolfssl.txt on how to set this up)

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

解决
https://yq.aliyun.com/articles/670111

yum install openssl-devel

这下完成了,构建源码这个很繁琐啊

官网也有教程

https://dev.mysql.com/doc/refman/5.7/en/source-installation.html

https://dev.mysql.com/doc/refman/8.0/en/installing-source-distribution.html
https://dev.mysql.com/doc/refman/5.7/en/postinstallation.html

你可能感兴趣的:(linux)