官方文档
https://downloads.mysql.com/archives/community/
https://dev.mysql.com/doc/refman/8.1/en/binary-installation.html
官方文档源码安装步骤
# Preconfiguration setup
$> groupadd mysql
$> useradd -r -g mysql -s /bin/false mysql
# Beginning of source-build specific instructions
$> tar zxvf mysql-VERSION.tar.gz
$> cd mysql-VERSION
$> mkdir bld
$> cd bld
$> cmake ..
$> make
$> make install
# End of source-build specific instructions
# Postinstallation setup
$> cd /usr/local/mysql
$> mkdir mysql-files
$> chown mysql:mysql mysql-files
$> chmod 750 mysql-files
$> bin/mysqld --initialize --user=mysql
$> bin/mysql_ssl_rsa_setup
$> bin/mysqld_safe --user=mysql &
# Next command is optional
$> cp support-files/mysql.server /etc/init.d/mysql.server
下载源码
https://dev.mysql.com/get/Downloads/MySQL-8.1/mysql-8.1.0.tar.gz
[root@node01 ~]# wget https://dev.mysql.com/get/Downloads/MySQL-8.1/mysql-8.1.0.tar.gz
源码安装先决条件
1、gcc和cmake版本要求
Linux:GCC 7.1 或 Clang 5
CMake:3.75
2、依赖包
cmake、make、automake、autoconf、gcc、gcc-c++、ncurses-devel、openssl-devel、libmcrypt
3、安装依赖包
[root@node01 ~]# yum install cmake make gcc gcc-c++ autoconf automake openssl openssl-devel ncurses-devel libmcrypt* -y
4、卸载mariadb
[root@node01 ~]# yum remove mariadb -y
5、删除配置文件
[root@node01 ~]# rm -rf /etc/my.cnf
升级gcc
1、操作系统版本
[root@node01 ~]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
2、查看gcc版本
[root@node01 ~]# gcc -v
gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
3、安装scl
[root@node01 ~]# yum install centos-release-scl -y
[root@node01 ~]# yum list |grep gcc
4、安装gcc8
[root@node01 ~]# yum install -y devtoolset-8-gcc*
5、临时切换gcc
[root@node01 ~]# source /opt/rh/devtoolset-8/enable
6、查看gcc版本
[root@node01 ~]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-8/root/usr --mandir=/opt/rh/devtoolset-8/root/usr/share/man --infodir=/opt/rh/devtoolset-8/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-8.3.1-20190311/obj-x86_64-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.3.1 20190311 (Red Hat 8.3.1-3) (GCC)
升级cmake
1、cmake编译
[root@node01 bld]# cmake ..
-- Running cmake version 2.8.12.2
CMake Warning at CMakeLists.txt:82 (MESSAGE):
Please use cmak