MySQL8.1源码安装与部署

本文档详细介绍了MySQL8.1的源码安装步骤,包括下载源码、升级gcc和cmake、创建用户组和数据目录,以及编译安装、初始化数据库、配置环境变量等操作,最后通过systemctl服务进行管理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

官方文档



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
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值